int.format error handling
@@ -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)]
