(
zelf: PyRef<PyStr>,
spec: PyUtf8StrRef,
vm: &VirtualMachine,
)
| 989 | |
| 990 | #[pymethod] |
| 991 | fn __format__( |
| 992 | zelf: PyRef<PyStr>, |
| 993 | spec: PyUtf8StrRef, |
| 994 | vm: &VirtualMachine, |
| 995 | ) -> PyResult<PyRef<PyStr>> { |
| 996 | if spec.is_empty() { |
| 997 | return if zelf.class().is(vm.ctx.types.str_type) { |
| 998 | Ok(zelf) |
| 999 | } else { |
| 1000 | zelf.as_object().str(vm) |
| 1001 | }; |
| 1002 | } |
| 1003 | let zelf = zelf.try_into_utf8(vm)?; |
| 1004 | let s = FormatSpec::parse(spec.as_str()) |
| 1005 | .and_then(|format_spec| { |
| 1006 | format_spec.format_string(&CharLenStr(zelf.as_str(), zelf.char_len())) |
| 1007 | }) |
| 1008 | .map_err(|err| err.into_pyexception(vm))?; |
| 1009 | Ok(vm.ctx.new_str(s)) |
| 1010 | } |
| 1011 | |
| 1012 | #[pymethod] |
| 1013 | fn title(&self) -> Wtf8Buf { |
nothing calls this directly
no test coverage detected