mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
PEP 479: Change StopIteration handling inside generators.
Closes issue #22906.
This commit is contained in:
parent
bd60e8dece
commit
8170e8c0d1
14 changed files with 103 additions and 15 deletions
|
@ -443,12 +443,12 @@ is already executing raises a :exc:`ValueError` exception.
|
|||
.. method:: generator.close()
|
||||
|
||||
Raises a :exc:`GeneratorExit` at the point where the generator function was
|
||||
paused. If the generator function then raises :exc:`StopIteration` (by
|
||||
exiting normally, or due to already being closed) or :exc:`GeneratorExit` (by
|
||||
not catching the exception), close returns to its caller. If the generator
|
||||
yields a value, a :exc:`RuntimeError` is raised. If the generator raises any
|
||||
other exception, it is propagated to the caller. :meth:`close` does nothing
|
||||
if the generator has already exited due to an exception or normal exit.
|
||||
paused. If the generator function then exits gracefully, is already closed,
|
||||
or raises :exc:`GeneratorExit` (by not catching the exception), close
|
||||
returns to its caller. If the generator yields a value, a
|
||||
:exc:`RuntimeError` is raised. If the generator raises any other exception,
|
||||
it is propagated to the caller. :meth:`close` does nothing if the generator
|
||||
has already exited due to an exception or normal exit.
|
||||
|
||||
.. index:: single: yield; examples
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue