bpo-33346: Allow async comprehensions inside implicit async comprehensions (GH-6766)

Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
Serhiy Storchaka 2021-07-14 00:27:50 +03:00 committed by GitHub
parent 0ee0a740e1
commit 054e9c84ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 109 additions and 17 deletions

View file

@ -218,9 +218,9 @@ A comprehension in an :keyword:`!async def` function may consist of either a
:keyword:`!for` or :keyword:`!async for` clause following the leading
expression, may contain additional :keyword:`!for` or :keyword:`!async for`
clauses, and may also use :keyword:`await` expressions.
If a comprehension contains either :keyword:`!async for` clauses
or :keyword:`!await` expressions it is called an
:dfn:`asynchronous comprehension`. An asynchronous comprehension may
If a comprehension contains either :keyword:`!async for` clauses or
:keyword:`!await` expressions or other asynchronous comprehensions it is called
an :dfn:`asynchronous comprehension`. An asynchronous comprehension may
suspend the execution of the coroutine function in which it appears.
See also :pep:`530`.
@ -230,6 +230,11 @@ See also :pep:`530`.
.. versionchanged:: 3.8
``yield`` and ``yield from`` prohibited in the implicitly nested scope.
.. versionchanged:: 3.11
Asynchronous comprehensions are now allowed inside comprehensions in
asynchronous functions. Outer comprehensions implicitly become
asynchronous.
.. _lists: