py/compile: Do not await __aiter__ special method return value. #6272
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As per discussion in #6267, the final PEP492 spec says that the
__aiter__()
method should not return an awaitable. This PR changes the compiler to not compile in an await and updates the async for tests to match.Note that the test in
async_for2.py
has had to be more modified in behaviour as well as syntax as it can no longer yield in the__aiter__()
method. I've just removed the call toawait f()
and the matching output completely.Have run the UNIX port tests successfully on macOS and also tested with my own async iterable code on the ESP32 port.
Note: This will be a breaking change to any (not precompiled) code that currently defines
__aiter__
methods usingawait
.