@@ -623,37 +623,8 @@ mod builtins {
623623 modulus,
624624 } = args;
625625 match modulus {
626- None => vm. binary_op ( & x, & y, PyNumberBinaryOp :: Power , "pow" ) ,
627- Some ( z) => {
628- let try_pow_value = |obj : & PyObject ,
629- args : ( PyObjectRef , PyObjectRef , PyObjectRef ) |
630- -> Option < PyResult > {
631- let method = obj. get_class_attr ( identifier ! ( vm, __pow__) ) ?;
632- let result = match method. call ( args, vm) {
633- Ok ( x) => x,
634- Err ( e) => return Some ( Err ( e) ) ,
635- } ;
636- Some ( Ok ( PyArithmeticValue :: from_object ( vm, result) . into_option ( ) ?) )
637- } ;
638-
639- if let Some ( val) = try_pow_value ( & x, ( x. clone ( ) , y. clone ( ) , z. clone ( ) ) ) {
640- return val;
641- }
642-
643- if !x. class ( ) . is ( y. class ( ) ) {
644- if let Some ( val) = try_pow_value ( & y, ( x. clone ( ) , y. clone ( ) , z. clone ( ) ) ) {
645- return val;
646- }
647- }
648-
649- if !x. class ( ) . is ( z. class ( ) ) && !y. class ( ) . is ( z. class ( ) ) {
650- if let Some ( val) = try_pow_value ( & z, ( x. clone ( ) , y. clone ( ) , z. clone ( ) ) ) {
651- return val;
652- }
653- }
654-
655- Err ( vm. new_unsupported_ternop_error ( & x, & y, & z, "pow" ) )
656- }
626+ None => vm. _pow ( & x, & y, & vm. ctx . none ( ) ) ,
627+ Some ( z) => vm. _pow ( & x, & y, & z) ,
657628 }
658629 }
659630
0 commit comments