Message289781
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 "<stdin>", line 1, in <module>
OverflowError: cannot fit 'int' into an index-sized integer
>>> bool(range(1<<1000))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C ssize_t
Proposed patch makes bool() returning True if len() raises OverflowError.
This is an alternate solution of issue28876. |
|
Date |
User |
Action |
Args |
2017-03-17 20:27:26 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, mark.dickinson |
2017-03-17 20:27:26 | serhiy.storchaka | set | messageid: <1489782446.56.0.355449112547.issue29840@psf.upfronthosting.co.za> |
2017-03-17 20:27:26 | serhiy.storchaka | link | issue29840 messages |
2017-03-17 20:27:26 | serhiy.storchaka | create | |
|