This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jack1142
Recipients asvetlov, jack1142, yselivanov
Date 2020-02-05.17:28:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580923705.71.0.29233909242.issue39562@roundup.psfhosted.org>
In-reply-to
Content
asyncio REPL doesn't allow using asynchronous comprehensions outside of async func. Same behavior can also be observed when using `ast.PyCF_ALLOW_TOP_LEVEL_AWAIT` flag in `compile()`

Example with `async for`:
>>> async def async_gen():
...     for x in range(5):
...         yield await asyncio.sleep(1, x)
... 
>>> [x async for x in async_gen()]
  File "<console>", line 0
SyntaxError: asynchronous comprehension outside of an asynchronous function


Example with `await`:
>>> [await asyncio.sleep(1, x) for x in range(5)]
  File "<console>", line 0
SyntaxError: asynchronous comprehension outside of an asynchronous function
History
Date User Action Args
2020-02-05 17:28:25jack1142setrecipients: + jack1142, asvetlov, yselivanov
2020-02-05 17:28:25jack1142setmessageid: <1580923705.71.0.29233909242.issue39562@roundup.psfhosted.org>
2020-02-05 17:28:25jack1142linkissue39562 messages
2020-02-05 17:28:25jack1142create