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
better exception message when an unsupported object is passed to async for
(pep 492)
#69183
Comments
Should we raise something like "'int' object is not an asynchronous iterable", instead of "'async for' requires an object with __aiter__ method, got int"? >>> foo().send(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in foo
TypeError: 'async for' requires an object with __aiter__ method, got int
>>> for i in 1: pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not iterable |
Did you get multiple complaints about this? The existing error doesn't seem so bad. |
IMHO the current message is clear enough. |
I saw this reddit thread: https://www.reddit.com/r/Python/comments/3ewnwq/async_function_as_generator_for_async_for/ where people are struggling with understanding how 'async for' works. Which led me to check what error messages we raise when we pass a wrong object to it. Turns out the message is fine, but different from what we raise on iter(1) etc. |
In tandem with an "asynchronous iterable" glossary entry, that could be a nice improvement. Even without such a change the first hit for "python asynchronous iterable" is PEP-492, so it will get folks pointed in the right direction. |
Do what you think is best. |
FWIW the existing message is clear enough and this seems abandoned for over 7 years. I'll close this unless anyone objects otherwise. |
Just close it. |
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: