]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39545: Document restrictions on "await" and "async for" in f-strings. (GH-18459) 18722/head
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 13 Feb 2020 23:53:59 +0000 (01:53 +0200)
committerGitHub <noreply@github.com>
Thu, 13 Feb 2020 23:53:59 +0000 (18:53 -0500)
Doc/reference/compound_stmts.rst
Doc/reference/lexical_analysis.rst

index b4e95b90dbc70027219e55cccfb98e59676a36e3..8d050a69a931d2362ebcb8591060bb1d7cde6d4b 100644 (file)
@@ -730,7 +730,7 @@ Functions defined with ``async def`` syntax are always coroutine functions,
 even if they do not contain ``await`` or ``async`` keywords.
 
 It is a :exc:`SyntaxError` to use ``yield from`` expressions in
-``async def`` coroutines. Using ``await`` in :keyword:`f-strings` will also produce a :exc:`SyntaxError`.
+``async def`` coroutines.
 
 An example of a coroutine function::
 
index bee02443e621ffc180d6a8e59d2a85202a87ff3d..3a03b94716231ce73807e050217758263332f0fb 100644 (file)
@@ -683,6 +683,15 @@ can contain line breaks (e.g. in triple-quoted strings), but they
 cannot contain comments.  Each expression is evaluated in the context
 where the formatted string literal appears, in order from left to right.
 
+.. index::
+   keyword: await
+   single: async for; in comprehensions
+
+An :keyword:`await` expression and comprehensions containing an
+:keyword:`async for` clause are illegal in the expression in formatted
+string literals. (The reason is a problem with the implementation ---
+this restriction is lifted in Python 3.7).
+
 If a conversion is specified, the result of evaluating the expression
 is converted before formatting.  Conversion ``'!s'`` calls :func:`str` on
 the result, ``'!r'`` calls :func:`repr`, and ``'!a'`` calls :func:`ascii`.