(zelf: &Py<Self>, spec: PyUtf8StrRef, vm: &VirtualMachine)
| 255 | impl PyFloat { |
| 256 | #[pymethod] |
| 257 | fn __format__(zelf: &Py<Self>, spec: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<Wtf8Buf> { |
| 258 | // Empty format spec: equivalent to str(self) |
| 259 | if spec.is_empty() { |
| 260 | return Ok(zelf.as_object().str(vm)?.as_wtf8().to_owned()); |
| 261 | } |
| 262 | let format_spec = |
| 263 | FormatSpec::parse(spec.as_str()).map_err(|err| err.into_pyexception(vm))?; |
| 264 | let result = if format_spec.has_locale_format() { |
| 265 | let locale = crate::format::get_locale_info(); |
| 266 | format_spec.format_float_locale(zelf.value, &locale) |
| 267 | } else { |
| 268 | format_spec.format_float(zelf.value) |
| 269 | }; |
| 270 | result |
| 271 | .map(Wtf8Buf::from_string) |
| 272 | .map_err(|err| err.into_pyexception(vm)) |
| 273 | } |
| 274 | |
| 275 | #[pystaticmethod] |
| 276 | fn __getformat__(spec: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<String> { |
nothing calls this directly
no test coverage detected