File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4040assert (- 2 ).__divmod__ (3 ) == (- 1 , 1 )
4141with assertRaises (ZeroDivisionError ):
4242 (2 ).__divmod__ (0 )
43+ assert (- 3 ).__rdivmod__ (2 ) == (- 1 , - 1 )
4344assert (2 ).__pow__ (3 ) == 8
4445assert (10 ).__pow__ (- 1 ) == 0.1
4546assert (2 ).__rpow__ (3 ) == 9
Original file line number Diff line number Diff line change @@ -415,6 +415,16 @@ impl PyInt {
415415 }
416416 }
417417
418+ #[ pymethod( name = "__rdivmod__" ) ]
419+ fn rdivmod ( & self , other : PyObjectRef , vm : & VirtualMachine ) -> PyResult {
420+ if objtype:: isinstance ( & other, & vm. ctx . int_type ( ) ) {
421+ let other = other. payload :: < PyInt > ( ) . unwrap ( ) ;
422+ inner_divmod ( & other, self , vm)
423+ } else {
424+ Ok ( vm. ctx . not_implemented ( ) )
425+ }
426+ }
427+
418428 #[ pymethod( name = "__neg__" ) ]
419429 fn neg ( & self , _vm : & VirtualMachine ) -> BigInt {
420430 -( & self . value )
You can’t perform that action at this time.
0 commit comments