Skip to content

Commit 4d244f0

Browse files
committed
int.format error handling
1 parent a50ca74 commit 4d244f0

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

vm/src/builtins/int.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -589,12 +589,9 @@ impl PyInt {
589589

590590
#[pymethod(magic)]
591591
fn format(&self, spec: PyStrRef, vm: &VirtualMachine) -> PyResult<String> {
592-
match FormatSpec::parse(spec.as_str())
592+
FormatSpec::parse(spec.as_str())
593593
.and_then(|format_spec| format_spec.format_int(&self.value))
594-
{
595-
Ok(string) => Ok(string),
596-
Err(err) => Err(vm.new_value_error(err.to_string())),
597-
}
594+
.map_err(|msg| vm.new_value_error(msg.to_owned()))
598595
}
599596

600597
#[pymethod(magic)]

0 commit comments

Comments
 (0)