-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected errors in __iter__ are masked in "in" and the operator module #85001
Comments
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 bpo-26407. |
@serhiy, you have opened PRs for this for 3.7 and 3.6, both of which are now in the security-fix phase of their release cycles. It looks like this behavior has been around for a long time and does not appear to be a security issue. Unless there is some important reason why this behavior should be changed in a security fix release (for 3.6) or as a release critical fix for 3.7.8 final and unless another core developer reviews the changes, I do not think the PRs should be merged to 3.7 or 3.6. |
Sorry, I was not sure which versions are in security-fix phase now. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: