Skip to content

Commit 722dbdf

Browse files
committed
Merge branch 'main' of https://github.com/python/cpython into pep-788
2 parents 43b0798 + 40dc61a commit 722dbdf

36 files changed

Lines changed: 2750 additions & 1744 deletions

.github/workflows/documentation-links.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/reusable-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
with:
5757
python-version: '3'
5858
cache: 'pip'
59-
cache-dependency-path: 'Doc/requirements.txt'
59+
cache-dependency-path: 'Doc/pylock.toml'
6060
- name: 'Install build dependencies'
6161
run: make -C Doc/ venv
6262

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ JOBS = auto
1313
PAPER =
1414
SOURCES =
1515
DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
16-
REQUIREMENTS = requirements.txt
16+
REQUIREMENTS = pylock.toml
1717
SPHINXERRORHANDLING = --fail-on-warning
1818

1919
# Internal variables.

Doc/library/ast.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ The abstract grammar is currently defined as follows:
3535
:language: asdl
3636

3737

38+
.. _ast_nodes:
39+
3840
Node classes
3941
------------
4042

@@ -164,8 +166,7 @@ Node classes
164166
Previous versions of Python allowed the creation of AST nodes that were missing
165167
required fields. Similarly, AST node constructors allowed arbitrary keyword
166168
arguments that were set as attributes of the AST node, even if they did not
167-
match any of the fields of the AST node. This behavior is deprecated and will
168-
be removed in Python 3.15.
169+
match any of the fields of the AST node. These cases now raise a :exc:`TypeError`.
169170

170171
.. note::
171172
The descriptions of the specific node classes displayed here

Doc/library/asyncio-task.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ Example::
394394
The ``async with`` statement will wait for all tasks in the group to finish.
395395
While waiting, new tasks may still be added to the group
396396
(for example, by passing ``tg`` into one of the coroutines
397-
and calling ``tg.create_task()`` in that coroutine). There is also opportunity
398-
to short-circuit the entire task group with ``tg.cancel()``, based on some condition.
397+
and calling ``tg.create_task()`` in that coroutine). There is also opportunity to
398+
request termination of the entire task group with ``tg.cancel()``, based on some condition.
399399
Once the last task has finished and the ``async with`` block is exited,
400400
no new tasks may be added to the group.
401401

Doc/library/contextlib.rst

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,40 @@ Functions and classes provided:
467467
statements. If this is not the case, then the original construct with the
468468
explicit :keyword:`!with` statement inside the function should be used.
469469

470+
When the decorated callable is a generator function, coroutine function, or
471+
asynchronous generator function, the returned wrapper is of the same kind
472+
and keeps the context manager open for the lifetime of the iteration or
473+
await rather than only for the call that creates the generator or coroutine
474+
object. Wrapped generators and asynchronous generators are explicitly
475+
closed when iteration ends, as if by :func:`closing` or :func:`aclosing`.
476+
477+
.. note::
478+
For asynchronous generators the wrapper re-yields each value with
479+
``async for``; values sent with :meth:`~agen.asend` and exceptions
480+
thrown with :meth:`~agen.athrow` are not forwarded to the wrapped
481+
generator.
482+
470483
.. versionadded:: 3.2
471484

485+
.. versionchanged:: next
486+
Decorating a generator function, coroutine function, or asynchronous
487+
generator function now keeps the context manager open across iteration
488+
or await. Previously the context manager exited as soon as the
489+
generator or coroutine object was created.
490+
472491

473492
.. class:: AsyncContextDecorator
474493

475-
Similar to :class:`ContextDecorator` but only for asynchronous functions.
494+
Similar to :class:`ContextDecorator`, but the context manager is entered
495+
and exited with :keyword:`async with`. Decorate coroutine functions and
496+
asynchronous generator functions with this class; the returned wrapper is
497+
of the same kind.
498+
499+
.. note::
500+
Synchronous functions and generators are accepted, but the wrapper is
501+
always asynchronous, so the decorated callable must then be awaited or
502+
iterated with ``async for``. If that change of calling convention is
503+
not intended, use :class:`ContextDecorator` instead.
476504

477505
Example of ``AsyncContextDecorator``::
478506

@@ -510,6 +538,13 @@ Functions and classes provided:
510538

511539
.. versionadded:: 3.10
512540

541+
.. versionchanged:: next
542+
Decorating an asynchronous generator function now keeps the context
543+
manager open across iteration. Previously the context manager exited
544+
as soon as the generator object was created. Synchronous functions
545+
and synchronous generator functions are also now accepted, with an
546+
asynchronous wrapper returned.
547+
513548

514549
.. class:: ExitStack()
515550

Doc/make.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if not defined SPHINXBUILD (
1313
%PYTHON% -c "import sphinx" > nul 2> nul
1414
if errorlevel 1 (
1515
echo Installing sphinx with %PYTHON%
16-
%PYTHON% -m pip install -r requirements.txt
16+
%PYTHON% -m pip install -r pylock.toml
1717
if errorlevel 1 exit /B
1818
)
1919
set SPHINXBUILD=%PYTHON% -c "import sphinx.cmd.build, sys; sys.exit(sphinx.cmd.build.main())"

0 commit comments

Comments
 (0)