Issue #19437: Fix convert_op_cmp() of decimal.Decimal rich comparator, handle

PyObject_IsInstance() failure
This commit is contained in:
Victor Stinner 2013-10-29 19:26:11 +01:00
parent 7165d8b9ba
commit a992e11fe3
1 changed files with 17 additions and 10 deletions

View File

@ -3009,18 +3009,25 @@ convert_op_cmp(PyObject **vcmp, PyObject **wcmp, PyObject *v, PyObject *w,
*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) {