[issue29840] Avoid raising OverflowError in bool()

2017-04-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This was documented in issue15718. -- resolution: -> wont fix stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue29840] Avoid raising OverflowError in bool()

2017-04-22 Thread STINNER Victor
STINNER Victor added the comment: If someone wants to return a value larger than maxsize and support bool(): it is already possible right now by defining a __bool__ method no? If yes, I suggest to only document this CPython implementation detail (consequence of slots, for efficiency) and suggest

[issue29840] Avoid raising OverflowError in bool()

2017-04-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I had similar doubts about this patch and needed opinions of other core developers. > Maybe, if __len__() raises an OverflowError: call again the len(), but using > the "__len__" method instead of the slot? Following patch implements this idea. I don't

[issue29840] Avoid raising OverflowError in bool()

2017-04-21 Thread STINNER Victor
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

[issue29840] Avoid raising OverflowError in bool()

2017-04-20 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- pull_requests: +1333 ___ Python tracker ___ ___

[issue29840] Avoid raising OverflowError in bool()

2017-03-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This issue depends on issue29839. Tests are failed until the patch of issue29839 is merged. -- ___ Python tracker

[issue29840] Avoid raising OverflowError in bool()

2017-03-27 Thread STINNER Victor
STINNER Victor added the comment: Serhiy: Can you please create a pull request? It would be easier to review. -- nosy: +haypo ___ Python tracker ___

[issue29840] Avoid raising OverflowError in bool()

2017-03-24 Thread Terry J. Reedy
Terry J. Reedy added the comment: https://docs.python.org/3/library/functions.html#bool refers to https://docs.python.org/3/library/stdtypes.html#truth The latter says that values are true ("All other values are considered true") unless one of certain conditions holds. For user-defined

[issue29840] Avoid raising OverflowError in bool()

2017-03-17 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- dependencies: +Avoid raising OverflowError in len() when __len__() returns negative large value keywords: +patch Added file: http://bugs.python.org/file46731/bool-overflow.diff ___ Python

[issue29840] Avoid raising OverflowError in bool()

2017-03-17 Thread Serhiy Storchaka
New submission from Serhiy Storchaka: For now bool() raises OverflowError if __bool__ is not defined and __len__ returns large value. >>> class A: ... def __len__(self): ... return 1 << 1000 ... >>> bool(A()) Traceback (most recent call last): File "", line 1, in OverflowError: