You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Some missing error checks on _PyObject_LookupSpecial in bytes and weakref #159430
A robot reported these bugs to me while I had it trying to collect a list of examples of something tangentially related.
In format_obj in bytes and weakref_repr in weakref.ref, we don't check PyErr_Occurred() after a NULL return from _PyObject_LookupSpecial. Pretty marginal tbh but it triggers "returned a result with an exception set".
# bytes %-formatting ignores an error from looking up __bytes__
class BadBytes:
@property
def __bytes__(self):
raise AssertionError('oop')
def __buffer__(self, flags):
return memoryview(b'abc')
b'%b' % BadBytes()
# SystemError: <class 'memoryview'> returned a result with an exception set
# weakref repr() ignores an error from looking up __name__
import weakref
class BadName:
@property
def __name__(self):
raise AssertionError('oop')
obj = BadName()
repr(weakref.ref(obj))
# SystemError: <built-in function repr> returned a result with an exception set
Activity
pythongh-159430: Add _PyObject_LookupSpecial error checks in bytes/we…