Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34.3k
Open
Description
Bug report
Bug description:
This is a sub-issue for#146102 and more details can be foundhere.
Incode_richcompare on line 2608,PyObject_RichCompareBool can return an error (-1), but that is treated incorrectly since!(-1) == 0. Reproducer:
classBadStr(str):_armed=Falsedef__eq__(self,other):ifBadStr._armedandisinstance(other,str)andstr.__eq__(self,other):raiseRuntimeError("Poison!")returnstr.__eq__(self,other)def__hash__(self):returnstr.__hash__(self)c1=compile("pass","test","exec")c2=c1.replace(co_name=BadStr("poison"))c3=compile("pass","poison","exec")BadStr._armed=Truec2==c3# assertion: !_PyErr_Occurred(tstate)
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux