8000 gh-115528: Update language reference for PEP 646 by mrahtz · Pull Request #121181 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-115528: Update language reference for PEP 646 #121181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix some whitespace changes
  • Loading branch information
mrahtz committed Jun 30, 2024
commit b8e2f02bb667ebda630a302bdcf7797eeec5f5ac
41 changes: 20 additions & 21 deletions Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@
generator. That generator then controls the execution of the generator
function. The execution starts when one of the generator's methods is called.
At that time, the execution proceeds to the first yield expression, where it is
suspended again, returning the value of
:token:`~python-grammar:expression_list` to the generator's caller,
suspended again, returning the value of :token:`~python-grammar:expression_list`
to the generator's caller,
or ``None`` if :token:`~python-grammar:expression_list` is omitted.
By suspended, we mean that all local state is
retained, including the current bindings of local variables, the instruction
Expand Down Expand Up @@ -545,9 +545,9 @@
:meth:`~generator.__next__` method, the current yield expression always
evaluates to :const:`None`. The execution then continues to the next yield
expression, where the generator is suspended again, and the value of the
:token:`~python-grammar:expression_list` is returned to
:meth:`__next__`'s caller. If the generator exits without yielding another
value, a :exc:`StopIteration` exception is raised.
:token:`~python-grammar:expression_list` is returned to :meth:`__next__`'s
caller. If the generator exits without yielding another value, a
:exc:`StopIteration` exception is raised.

This method is normally called implicitly, e.g. by a :keyword:`for` loop, or
by the built-in :func:`next` function.
Expand Down Expand Up @@ -664,17 +664,17 @@
Calling one of the asynchronous generator's methods returns an :term:`awaitable`
object, and the execution starts when this object is awaited on. At that time,
the execution proceeds to the first yield expression, where it is suspended
again, returning the value of :token:`~python-grammar:expression_list`
to the awaiting coroutine. As with a generator, suspension means that all local
state is retained, including the current bindings of local variables, the
instruction pointer, the internal evaluation stack, and the state of any
exception handling. When the execution is resumed by awaiting on the next object
returned by the asynchronous generator's methods, the function can proceed
exactly as if the yield expression were just another external call. The value of
the yield expression after resuming depends on the method which resumed the
execution. If :meth:`~agen.__anext__` is used then the result is :const:`None`.
Otherwise, if :meth:`~agen.asend` is used, then the result will be the value
passed in to that method.
again, returning the value of :token:`~python-grammar:expression_list` to the
awaiting coroutine. As with a generator, suspension means that all local state
is retained, including the current bindings of local variables, the instruction
pointer, the internal evaluation stack, and the state of any exception handling.
When the execution is resumed by awaiting on the next object returned by the
asynchronous generator's methods, the function can proceed exactly as if the
yield expression were just another external call. The value of the yield
expression after resuming depends on the method which resumed the execution. If
:meth:`~agen.__anext__` is used then the result is :const:`None`. Otherwise, if
:meth:`~agen.asend` is used, then the result will be the value passed in to that
method.

If an asynchronous generator happens to exit early by :keyword:`break`, the caller
task being cancelled, or other exceptions, the generator's async cleanup code
Expand Down Expand Up @@ -728,10 +728,10 @@
asynchronous generator function is resumed with an :meth:`~agen.__anext__`
method, the current yield expression always evaluates to :const:`None` in the
returned awaitable, which when run will continue to the next yield
expression. The value of the :token:`~python-grammar:expression_list`
of the yield expression is the value of the :exc:`StopIteration` exception
raised by the completing coroutine. If the asynchronous generator exits
without yielding another value, the awaitable instead raises a
expression. The value of the :token:`~python-grammar:expression_list` of the
yield expression is the value of the :exc:`StopIteration` exception raised by
the completing coroutine. If the asynchronous generator exits without
yielding another value, the awaitable instead raises a
:exc:`StopAsyncIteration` exception, signalling that the asynchronous
iteration has completed.

Expand Down Expand Up @@ -1877,8 +1877,7 @@
pair: expression; list
single: , (comma); expression list

.. productionlist:: python-grammar

Check warning on line 1880 in Doc/reference/expressions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'token' reference target not found: python-grammar:flexible_expression

Check warning on line 1880 in Doc/reference/expressions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'token' reference target not found: python-grammar:flexible_expression

Check warning on line 1880 in Doc/reference/expressions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

'token' reference target not found: python-grammar:starred_expression_list

expression_list: `flexible_expression` ("," `flexible_expression`)* [","]
yield_list: `expression` ["," `starred_expression_list`]
| `starred_expression` "," [`starred_expression_list`]
Expand Down
Loading
0