*wcmp = Py_NotImplemented;
}
}
- else if (PyObject_IsInstance(w, Rational)) {
- *wcmp = numerator_as_decimal(w, context);
- if (*wcmp && !mpd_isspecial(MPD(v))) {
- *vcmp = multiply_by_denominator(v, w, context);
- if (*vcmp == NULL) {
- Py_CLEAR(*wcmp);
+ else {
+ int is_instance = PyObject_IsInstance(w, Rational);
+ if (is_instance < 0) {
+ *wcmp = NULL;
+ return 0;
+ }
+ if (is_instance) {
+ *wcmp = numerator_as_decimal(w, context);
+ if (*wcmp && !mpd_isspecial(MPD(v))) {
+ *vcmp = multiply_by_denominator(v, w, context);
+ if (*vcmp == NULL) {
+ Py_CLEAR(*wcmp);
+ }
}
}
- }
- else {
- Py_INCREF(Py_NotImplemented);
- *wcmp = Py_NotImplemented;
+ else {
+ Py_INCREF(Py_NotImplemented);
+ *wcmp = Py_NotImplemented;
+ }
}
if (*wcmp == NULL || *wcmp == Py_NotImplemented) {