(zelf: &Py<Self>, spec: PyUtf8StrRef, vm: &VirtualMachine)
| 355 | |
| 356 | #[pymethod] |
| 357 | fn __format__(zelf: &Py<Self>, spec: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<Wtf8Buf> { |
| 358 | // Empty format spec: equivalent to str(self) |
| 359 | if spec.is_empty() { |
| 360 | return Ok(zelf.as_object().str(vm)?.as_wtf8().to_owned()); |
| 361 | } |
| 362 | let format_spec = |
| 363 | FormatSpec::parse(spec.as_str()).map_err(|err| err.into_pyexception(vm))?; |
| 364 | let result = if format_spec.has_locale_format() { |
| 365 | let locale = crate::format::get_locale_info(); |
| 366 | format_spec.format_complex_locale(&zelf.value, &locale) |
| 367 | } else { |
| 368 | format_spec.format_complex(&zelf.value) |
| 369 | }; |
| 370 | result |
| 371 | .map(Wtf8Buf::from_string) |
| 372 | .map_err(|err| err.into_pyexception(vm)) |
| 373 | } |
| 374 | |
| 375 | #[pyclassmethod] |
| 376 | fn from_number(cls: PyTypeRef, number: PyObjectRef, vm: &VirtualMachine) -> PyResult { |
nothing calls this directly
no test coverage detected