File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 40
40
assert (- 2 ).__divmod__ (3 ) == (- 1 , 1 )
41
41
with assertRaises (ZeroDivisionError ):
42
42
(2 ).__divmod__ (0 )
43
+ assert (- 3 ).__rdivmod__ (2 ) == (- 1 , - 1 )
43
44
assert (2 ).__pow__ (3 ) == 8
44
45
assert (10 ).__pow__ (- 1 ) == 0.1
45
46
assert (2 ).__rpow__ (3 ) == 9
Original file line number Diff line number Diff line change @@ -415,6 +415,16 @@ impl PyInt {
415
415
}
416
416
}
417
417
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
+
418
428
#[ pymethod( name = "__neg__" ) ]
419
429
fn neg ( & self , _vm : & VirtualMachine ) -> BigInt {
420
430
-( & self . value )
You can’t perform that action at this time.
0 commit comments