FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-135110: Fix misleading generator.close() documentation by cdenihan · Pull Request #135152 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion Doc/howto/functional.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ generators:
raise an exception inside the generator; the exception is raised by the
``yield`` expression where the generator's execution is paused.

* :meth:`~generator.close` raises a :exc:`GeneratorExit` exception inside the
* :meth:`~generator.close` sends a :exc:`GeneratorExit` exception to the
generator to terminate the iteration. On receiving this exception, the
generator's code must either raise :exc:`GeneratorExit` or
:exc:`StopIteration`; catching the exception and doing anything else is
Expand Down
6 changes: 4 additions & 2 deletions Doc/reference/expressions.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,10 @@ 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 catches the exception and returns a
Raises a :exc:`GeneratorExit` exception at the point where the generator
function was paused (equivalent to calling ``throw(GeneratorExit)``).
The exception is raised by the yield expression where the generator was paused.
If the generator function catches the exception and returns a
value, this value is returned from :meth:`close`. If the generator function
is already closed, or raises :exc:`GeneratorExit` (by not catching the
exception), :meth:`close` returns :const:`None`. If the generator yields a
Expand Down

Back | FazBrowse Home | New Git URL