Skip to content

Commit 0aad7e6

Browse files
committed
Fix docs
1 parent b3cbdb6 commit 0aad7e6

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Doc/library/exceptions.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,17 +367,21 @@ The following exceptions are the exceptions that are usually raised.
367367
raised, and the value returned by the function is used as the
368368
:attr:`value` parameter to the constructor of the exception.
369369

370-
If a generator function defined in the presence of a ``from __future__
371-
import generator_stop`` directive raises :exc:`StopIteration`, it will be
372-
converted into a :exc:`RuntimeError` (retaining the :exc:`StopIteration`
373-
as the new exception's cause).
370+
If a generator code directly or indirectly raises :exc:`StopIteration`,
371+
it is converted into a :exc:`RuntimeError` (retaining the
372+
:exc:`StopIteration` as the new exception's cause).
374373

375374
.. versionchanged:: 3.3
376375
Added ``value`` attribute and the ability for generator functions to
377376
use it to return a value.
378377

379378
.. versionchanged:: 3.5
380-
Introduced the RuntimeError transformation.
379+
Introduced the RuntimeError transformation via
380+
``from __future__ import generator_stop``, see :pep:`479`.
381+
382+
.. versionchanged:: 3.7
383+
Enable :pep:`479` for all code by default: a :exc:`StopIteration`
384+
error raised in a generator is transformed into a :exc:`RuntimeError`.
381385

382386
.. exception:: StopAsyncIteration
383387

Doc/whatsnew/3.7.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,12 @@ that may require changes to your code.
935935
Changes in Python behavior
936936
--------------------------
937937

938+
* :pep:`479` is enabled for all code in Python 3.7, meaning that
939+
:exc:`StopIteration` exceptions raised directly or indirectly in
940+
coroutines and generators are transformed into :exc:`RuntimeError`
941+
exceptions.
942+
(Contributed by Yury Selivanov in :issue:`32670`.)
943+
938944
* Due to an oversight, earlier Python versions erroneously accepted the
939945
following syntax::
940946

0 commit comments

Comments
 (0)