@@ -430,7 +430,7 @@ extern "C" Box* intAdd(BoxedInt* lhs, Box* rhs) {
430430 if (PyInt_Check (rhs)) {
431431 BoxedInt* rhs_int = static_cast <BoxedInt*>(rhs);
432432 return add_i64_i64 (lhs->n , rhs_int->n );
433- } else if (PyFloat_Check (rhs)) {
433+ } else if (PyFloat_CheckExact (rhs)) {
434434 BoxedFloat* rhs_float = static_cast <BoxedFloat*>(rhs);
435435 return boxFloat (lhs->n + rhs_float->d );
436436 } else {
@@ -559,7 +559,7 @@ extern "C" Box* intDiv(BoxedInt* lhs, Box* rhs) {
559559
560560 if (PyInt_Check (rhs)) {
561561 return intDivInt (lhs, static_cast <BoxedInt*>(rhs));
562- } else if (PyFloat_Check (rhs)) {
562+ } else if (PyFloat_CheckExact (rhs)) {
563563 return intDivFloat (lhs, static_cast <BoxedFloat*>(rhs));
564564 } else {
565565 return NotImplemented;
@@ -601,7 +601,7 @@ extern "C" Box* intFloordiv(BoxedInt* lhs, Box* rhs) {
601601
602602 if (PyInt_Check (rhs)) {
603603 return intFloordivInt (lhs, static_cast <BoxedInt*>(rhs));
604- } else if (PyFloat_Check (rhs)) {
604+ } else if (PyFloat_CheckExact (rhs)) {
605605 return intFloordivFloat (lhs, static_cast <BoxedFloat*>(rhs));
606606 } else {
607607 return NotImplemented;
@@ -647,7 +647,7 @@ extern "C" Box* intTruediv(BoxedInt* lhs, Box* rhs) {
647647
648648 if (PyInt_Check (rhs)) {
649649 return intTruedivInt (lhs, static_cast <BoxedInt*>(rhs));
650- } else if (PyFloat_Check (rhs)) {
650+ } else if (PyFloat_CheckExact (rhs)) {
651651 return intTruedivFloat (lhs, static_cast <BoxedFloat*>(rhs));
652652 } else {
653653 return NotImplemented;
@@ -790,7 +790,7 @@ extern "C" Box* intMul(BoxedInt* lhs, Box* rhs) {
790790 if (PyInt_Check (rhs)) {
791791 BoxedInt* rhs_int = static_cast <BoxedInt*>(rhs);
792792 return intMulInt (lhs, rhs_int);
793- } else if (PyFloat_Check (rhs)) {
793+ } else if (PyFloat_CheckExact (rhs)) {
794794 BoxedFloat* rhs_float = static_cast <BoxedFloat*>(rhs);
795795 return intMulFloat (lhs, rhs_float);
796796 } else {
@@ -842,7 +842,7 @@ extern "C" Box* intPow(BoxedInt* lhs, Box* rhs, Box* mod) {
842842
843843 if (PyLong_Check (rhs))
844844 return intPowLong (lhs, static_cast <BoxedLong*>(rhs), mod);
845- else if (PyFloat_Check (rhs))
845+ else if (PyFloat_CheckExact (rhs))
846846 return intPowFloat (lhs, static_cast <BoxedFloat*>(rhs), mod);
847847 else if (!PyInt_Check (rhs))
848848 return NotImplemented;
@@ -937,7 +937,7 @@ extern "C" Box* intSub(BoxedInt* lhs, Box* rhs) {
937937 if (PyInt_Check (rhs)) {
938938 BoxedInt* rhs_int = static_cast <BoxedInt*>(rhs);
939939 return intSubInt (lhs, rhs_int);
940- } else if (PyFloat_Check (rhs)) {
940+ } else if (PyFloat_CheckExact (rhs)) {
941941 BoxedFloat* rhs_float = static_cast <BoxedFloat*>(rhs);
942942 return intSubFloat (lhs, rhs_float);
943943 } else {
0 commit comments