[issue29840] Avoid raising OverflowError in bool()
STINNER Victor
report at bugs.python.org
Fri Apr 21 12:34:42 EDT 2017
STINNER Victor added the comment:
Hum, I dislike this change since it's non-obvious what/who is raising the OverflowError. If an object calls a function in __len__() and the function raises OverflowError, should we consider that object is "true"? In temptation to guess, I prefer to not guess but passthrough the exception.
If you want to support bool(range(1<<1000)), we need to get the result of __len__() as a Python object rather than a C Py_ssize_t.
Maybe, if __len__() raises an OverflowError: call again the len(), but using the "__len__" method instead of the slot?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29840>
_______________________________________
More information about the Python-bugs-list
mailing list