summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-02-04 08:53:48 (GMT)
committerGitHub <noreply@github.com>2018-02-04 08:53:48 (GMT)
commit07ca9afaa8768b44baf816b4998d209ed3e0088f (patch)
treeacb09f5cd6a660acb41d77c150cdd6236bf02d96 /Doc
parent8b5fa289fdb04b6b919cf95fa99246aa872e47a8 (diff)
downloadcpython-07ca9afaa8768b44baf816b4998d209ed3e0088f.zip
cpython-07ca9afaa8768b44baf816b4998d209ed3e0088f.tar.gz
cpython-07ca9afaa8768b44baf816b4998d209ed3e0088f.tar.bz2
bpo-10544: Disallow "yield" in comprehensions and generator expressions. (GH-4564)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/reference/expressions.rst23
-rw-r--r--Doc/whatsnew/3.8.rst9
2 files changed, 18 insertions, 14 deletions
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index fb92ad0..151062b 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -196,8 +196,7 @@ they may depend on the values obtained from the leftmost iterable. For example:
To ensure the comprehension always results in a container of the appropriate
type, ``yield`` and ``yield from`` expressions are prohibited in the implicitly
-nested scope (in Python 3.7, such expressions emit :exc:`DeprecationWarning`
-when compiled, in Python 3.8+ they will emit :exc:`SyntaxError`).
+nested scope.
Since Python 3.6, in an :keyword:`async def` function, an :keyword:`async for`
clause may be used to iterate over a :term:`asynchronous iterator`.
@@ -214,8 +213,8 @@ See also :pep:`530`.
.. versionadded:: 3.6
Asynchronous comprehensions were introduced.
-.. deprecated:: 3.7
- ``yield`` and ``yield from`` deprecated in the implicitly nested scope.
+.. versionchanged:: 3.8
+ ``yield`` and ``yield from`` prohibited in the implicitly nested scope.
.. _lists:
@@ -350,9 +349,7 @@ The parentheses can be omitted on calls with only one argument. See section
To avoid interfering with the expected operation of the generator expression
itself, ``yield`` and ``yield from`` expressions are prohibited in the
-implicitly defined generator (in Python 3.7, such expressions emit
-:exc:`DeprecationWarning` when compiled, in Python 3.8+ they will emit
-:exc:`SyntaxError`).
+implicitly defined generator.
If a generator expression contains either :keyword:`async for`
clauses or :keyword:`await` expressions it is called an
@@ -368,8 +365,8 @@ which is an asynchronous iterator (see :ref:`async-iterators`).
only appear in :keyword:`async def` coroutines. Starting
with 3.7, any function can use asynchronous generator expressions.
-.. deprecated:: 3.7
- ``yield`` and ``yield from`` deprecated in the implicitly nested scope.
+.. versionchanged:: 3.8
+ ``yield`` and ``yield from`` prohibited in the implicitly nested scope.
.. _yieldexpr:
@@ -401,12 +398,10 @@ coroutine function to be an asynchronous generator. For example::
Due to their side effects on the containing scope, ``yield`` expressions
are not permitted as part of the implicitly defined scopes used to
-implement comprehensions and generator expressions (in Python 3.7, such
-expressions emit :exc:`DeprecationWarning` when compiled, in Python 3.8+
-they will emit :exc:`SyntaxError`)..
+implement comprehensions and generator expressions.
-.. deprecated:: 3.7
- Yield expressions deprecated in the implicitly nested scopes used to
+.. versionchanged:: 3.8
+ Yield expressions prohibited in the implicitly nested scopes used to
implement comprehensions and generator expressions.
Generator functions are described below, while asynchronous generator
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 8a3f9b0..c4063ad 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -113,6 +113,15 @@ This section lists previously described changes and other bugfixes
that may require changes to your code.
+Changes in Python behavior
+--------------------------
+
+* Yield expressions (both ``yield`` and ``yield from`` clauses) are now disallowed
+ in comprehensions and generator expressions (aside from the iterable expression
+ in the leftmost :keyword:`for` clause).
+ (Contributed by Serhiy Storchaka in :issue:`10544`.)
+
+
Changes in the Python API
-------------------------