Message370372
All errors raised in the __iter__ method are masked by the TypeError exception in the "in" operator and functions operator.contains(), operator.indexOf() and operator.countOf().
>>> class BadIterable:
... def __iter__(self):
... 1/0
...
>>>
>>> 1 in BadIterable()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument of type 'BadIterable' is not iterable
It includes exceptions out of control of the programmer like MemoryError and KeyboardInterrupt. Converting them to TypeError can lead to weird errors or incorrect results.
See also similar issue26407. |
|
Date |
User |
Action |
Args |
2020-05-30 11:36:12 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka |
2020-05-30 11:36:12 | serhiy.storchaka | set | messageid: <1590838572.36.0.635736065326.issue40824@roundup.psfhosted.org> |
2020-05-30 11:36:12 | serhiy.storchaka | link | issue40824 messages |
2020-05-30 11:36:12 | serhiy.storchaka | create | |
|