(zelf: &Py<Self>, spec: PyUtf8StrRef, vm: &VirtualMachine)
| 494 | |
| 495 | #[pymethod] |
| 496 | fn __format__(zelf: &Py<Self>, spec: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<Wtf8Buf> { |
| 497 | // Empty format spec on a subclass: equivalent to str(self) |
| 498 | if spec.is_empty() && !zelf.class().is(vm.ctx.types.int_type) { |
| 499 | return Ok(zelf.as_object().str(vm)?.as_wtf8().to_owned()); |
| 500 | } |
| 501 | let format_spec = |
| 502 | FormatSpec::parse(spec.as_str()).map_err(|err| err.into_pyexception(vm))?; |
| 503 | let result = if format_spec.has_locale_format() { |
| 504 | let locale = crate::format::get_locale_info(); |
| 505 | format_spec.format_int_locale(&zelf.value, &locale) |
| 506 | } else { |
| 507 | format_spec.format_int(&zelf.value) |
| 508 | }; |
| 509 | result |
| 510 | .map(Wtf8Buf::from_string) |
| 511 | .map_err(|err| err.into_pyexception(vm)) |
| 512 | } |
| 513 | |
| 514 | #[pymethod] |
| 515 | fn __sizeof__(&self) -> usize { |
nothing calls this directly
no test coverage detected