int.format error handling

This commit is contained in:
Jeong Yunwon
2022-05-04 08:12:01 +09:00
parent a50ca743dc
commit 4d244f0d07

View File

@@ -589,12 +589,9 @@ impl PyInt {
#[pymethod(magic)]
fn format(&self, spec: PyStrRef, vm: &VirtualMachine) -> PyResult<String> {
match FormatSpec::parse(spec.as_str())
FormatSpec::parse(spec.as_str())
.and_then(|format_spec| format_spec.format_int(&self.value))
{
Ok(string) => Ok(string),
Err(err) => Err(vm.new_value_error(err.to_string())),
}
.map_err(|msg| vm.new_value_error(msg.to_owned()))
}
#[pymethod(magic)]