Issue #19437: Fix convert_op_cmp() of decimal.Decimal rich comparator, handle
PyObject_IsInstance() failure
This commit is contained in:
parent
7165d8b9ba
commit
a992e11fe3
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue