Author serhiy.storchaka
Recipients serhiy.storchaka
Date 2020-05-30.11:36:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:12serhiy.storchakasetrecipients: + serhiy.storchaka
2020-05-30 11:36:12serhiy.storchakasetmessageid: <>
2020-05-30 11:36:12serhiy.storchakalinkissue40824 messages
2020-05-30 11:36:12serhiy.storchakacreate