Author serhiy.storchaka
Recipients serhiy.storchaka
Date 2020-05-30.11:36:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590838572.36.0.635736065326.issue40824@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-05-30 11:36:12serhiy.storchakasetrecipients: + serhiy.storchaka
2020-05-30 11:36:12serhiy.storchakasetmessageid: <1590838572.36.0.635736065326.issue40824@roundup.psfhosted.org>
2020-05-30 11:36:12serhiy.storchakalinkissue40824 messages
2020-05-30 11:36:12serhiy.storchakacreate