@@ -468,21 +468,18 @@ fn builtin_min(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
468
468
Ok ( x)
469
469
}
470
470
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 ! [ ] ) {
480
477
Ok ( value) => Ok ( value) ,
481
478
Err ( value) => {
482
479
if objtype:: isinstance ( & value, & vm. ctx . exceptions . stop_iteration ) {
483
480
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 ( ) ) ,
486
483
}
487
484
} else {
488
485
Err ( value)
@@ -491,10 +488,8 @@ fn builtin_next(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
491
488
}
492
489
}
493
490
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 ( ) ;
498
493
let s = if n. is_negative ( ) {
499
494
format ! ( "-0o{:o}" , n. abs( ) )
500
495
} else {
0 commit comments