File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -367,17 +367,21 @@ The following exceptions are the exceptions that are usually raised.
367
367
raised, and the value returned by the function is used as the
368
368
:attr: `value ` parameter to the constructor of the exception.
369
369
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).
374
373
375
374
.. versionchanged :: 3.3
376
375
Added ``value `` attribute and the ability for generator functions to
377
376
use it to return a value.
378
377
379
378
.. 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 `.
381
385
382
386
.. exception :: StopAsyncIteration
383
387
Original file line number Diff line number Diff line change @@ -935,6 +935,12 @@ that may require changes to your code.
935
935
Changes in Python behavior
936
936
--------------------------
937
937
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
+
938
944
* Due to an oversight, earlier Python versions erroneously accepted the
939
945
following syntax::
940
946
You can’t perform that action at this time.
0 commit comments