pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/1ce3f840be7823f6a898c31de19b200874a1b8a8

link crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-9c8f61f9f58ad7b2.css" /> Issue #19437: Fix convert_op_cmp() of decimal.Decimal rich comparator… · python/cpython@1ce3f84 · GitHub
Skip to content

Commit 1ce3f84

Browse files
committed
Issue #19437: Fix convert_op_cmp() of decimal.Decimal rich comparator, handle
PyObject_IsInstance() failure
1 parent 6decccd commit 1ce3f84

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

Modules/_decimal/_decimal.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,18 +3009,25 @@ convert_op_cmp(PyObject **vcmp, PyObject **wcmp, PyObject *v, PyObject *w,
30093009
*wcmp = Py_NotImplemented;
30103010
}
30113011
}
3012-
else if (PyObject_IsInstance(w, Rational)) {
3013-
*wcmp = numerator_as_decimal(w, context);
3014-
if (*wcmp && !mpd_isspecial(MPD(v))) {
3015-
*vcmp = multiply_by_denominator(v, w, context);
3016-
if (*vcmp == NULL) {
3017-
Py_CLEAR(*wcmp);
3012+
else {
3013+
int is_instance = PyObject_IsInstance(w, Rational);
3014+
if (is_instance < 0) {
3015+
*wcmp = NULL;
3016+
return 0;
3017+
}
3018+
if (is_instance) {
3019+
*wcmp = numerator_as_decimal(w, context);
3020+
if (*wcmp && !mpd_isspecial(MPD(v))) {
3021+
*vcmp = multiply_by_denominator(v, w, context);
3022+
if (*vcmp == NULL) {
3023+
Py_CLEAR(*wcmp);
3024+
}
30183025
}
30193026
}
3020-
}
3021-
else {
3022-
Py_INCREF(Py_NotImplemented);
3023-
*wcmp = Py_NotImplemented;
3027+
else {
3028+
Py_INCREF(Py_NotImplemented);
3029+
*wcmp = Py_NotImplemented;
3030+
}
30243031
}
30253032

30263033
if (*wcmp == NULL || *wcmp == Py_NotImplemented) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy