File tree 1 file changed +16
-7
lines changed
1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -438,12 +438,22 @@ impl VirtualMachine {
438
438
439
439
pub fn _sub ( & mut self , a : PyObjectRef , b : PyObjectRef ) -> PyResult {
440
440
// Try __sub__, next __rsub__, next, give up
441
- self . call_method ( & a, "__sub__" , vec ! [ b] )
442
- /*
443
- if a.has_attr("__sub__") {
444
- self.call_method(&a, "__sub__", vec![b])
445
- } else if b.has_attr("__rsub__") {
446
- self.call_method(&b, "__rsub__", vec![a])
441
+ if let Ok ( method) = self . get_method ( a. clone ( ) , "__sub__" ) {
442
+ self . invoke (
443
+ method,
444
+ PyFuncArgs {
445
+ args : vec ! [ b] ,
446
+ kwargs : vec ! [ ] ,
447
+ } ,
448
+ )
449
+ } else if let Ok ( method) = self . get_method ( b. clone ( ) , "__rsub__" ) {
450
+ self . invoke (
451
+ method,
452
+ PyFuncArgs {
453
+ args : vec ! [ a] ,
454
+ kwargs : vec ! [ ] ,
455
+ } ,
456
+ )
447
457
} else {
448
458
// Cannot sub a and b
449
459
let a_type_name = objtype:: get_type_name ( & a. typ ( ) ) ;
@@ -453,7 +463,6 @@ impl VirtualMachine {
453
463
a_type_name, b_type_name
454
464
) ) )
455
465
}
456
- */
457
466
}
458
467
459
468
pub fn _add ( & mut self , a : PyObjectRef , b : PyObjectRef ) -> PyResult {
You can’t perform that action at this time.
0 commit comments