https://github.com/python/cpython/commit/e23518fa96583d0190d457adb807b19545df26cf
commit: e23518fa96583d0190d457adb807b19545df26cf
branch: main
author: Pieter Eendebak <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2025-06-27T14:31:51+05:30
summary:
gh-136017: avoid decref in rich compare for bool objects (#136018)
files:
M Objects/object.c
diff --git a/Objects/object.c b/Objects/object.c
index 4d60128b092c22..1223983753ac46 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1131,11 +1131,14 @@ PyObject_RichCompareBool(PyObject *v, PyObject *w, int
op)
res = PyObject_RichCompare(v, w, op);
if (res == NULL)
return -1;
- if (PyBool_Check(res))
+ if (PyBool_Check(res)) {
ok = (res == Py_True);
- else
+ assert(_Py_IsImmortal(res));
+ }
+ else {
ok = PyObject_IsTrue(res);
- Py_DECREF(res);
+ Py_DECREF(res);
+ }
return ok;
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]