mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-136017: avoid decref in rich compare for bool objects (#136018)
This commit is contained in:
parent
07183ebce3
commit
e23518fa96
1 changed files with 6 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue