code_richcompare
This is a sub-issue for #146102 and more details can be found here.
In code_richcompare on line 2608, PyObject_RichCompareBool can return an error (-1), but that is treated incorrectly since !(-1) == 0 . Reproducer:
PyObject_RichCompareBool
!(-1) == 0
class BadStr(str): _armed = False def __eq__(self, other): if BadStr._armed and isinstance(other, str) and str.__eq__(self, other): raise RuntimeError("Poison!") return str.__eq__(self, other) def __hash__(self): return str.__hash__(self) c1 = compile("pass", "test", "exec") c2 = c1.replace(co_name=BadStr("poison")) c3 = compile("pass", "poison", "exec") BadStr._armed = True c2 == c3 # assertion: !_PyErr_Occurred(tstate)
CPython main branch
Linux
pythongh-146199: Fix error handling in `code_richcompare` when `PyObj…
gh-146199: Fix error handling in `code_richcompare` when `PyObject_Ri…
Merge branch 'fix-pythongh-138577' of github.com:CuriousLearner/cpyth…
Activity
pythongh-146199: Fix error handling in `code_richcompare` when `PyObj…
gh-146199: Fix error handling in `code_richcompare` when `PyObject_Ri…
Merge branch 'fix-pythongh-138577' of github.com:CuriousLearner/cpyth…
pythongh-146199: Fix error handling in `code_richcompare` when `PyObj…
pythongh-146199: Fix error handling in `code_richcompare` when `PyObj…