Skip to content

Commit b67ee2e

Browse files
committed
Convert next, oct
1 parent c1f8f1d commit b67ee2e

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

vm/src/builtins.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -468,21 +468,18 @@ fn builtin_min(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
468468
Ok(x)
469469
}
470470

471-
fn builtin_next(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
472-
arg_check!(
473-
vm,
474-
args,
475-
required = [(iterator, None)],
476-
optional = [(default_value, None)]
477-
);
478-
479-
match vm.call_method(iterator, "__next__", vec![]) {
471+
fn builtin_next(
472+
iterator: PyObjectRef,
473+
default_value: OptionalArg<PyObjectRef>,
474+
vm: &VirtualMachine,
475+
) -> PyResult {
476+
match vm.call_method(&iterator, "__next__", vec![]) {
480477
Ok(value) => Ok(value),
481478
Err(value) => {
482479
if objtype::isinstance(&value, &vm.ctx.exceptions.stop_iteration) {
483480
match default_value {
484-
None => Err(value),
485-
Some(value) => Ok(value.clone()),
481+
OptionalArg::Missing => Err(value),
482+
OptionalArg::Present(value) => Ok(value.clone()),
486483
}
487484
} else {
488485
Err(value)
@@ -491,10 +488,8 @@ fn builtin_next(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
491488
}
492489
}
493490

494-
fn builtin_oct(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
495-
arg_check!(vm, args, required = [(number, Some(vm.ctx.int_type()))]);
496-
497-
let n = objint::get_value(number);
491+
fn builtin_oct(number: PyIntRef, vm: &VirtualMachine) -> PyResult {
492+
let n = number.as_bigint();
498493
let s = if n.is_negative() {
499494
format!("-0o{:o}", n.abs())
500495
} else {

0 commit comments

Comments
 (0)