Commit 1ce3f840 authored by Victor Stinner's avatar Victor Stinner

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

PyObject_IsInstance() failure
parent 6decccda
......@@ -3009,7 +3009,13 @@ convert_op_cmp(PyObject **vcmp, PyObject **wcmp, PyObject *v, PyObject *w,
*wcmp = Py_NotImplemented;
}
}
else if (PyObject_IsInstance(w, Rational)) {
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);
......@@ -3022,6 +3028,7 @@ convert_op_cmp(PyObject **vcmp, PyObject **wcmp, PyObject *v, PyObject *w,
Py_INCREF(Py_NotImplemented);
*wcmp = Py_NotImplemented;
}
}
if (*wcmp == NULL || *wcmp == Py_NotImplemented) {
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment