Skip to content

Commit ebd1c28

Browse files
authored
Merge branch 'main' into gh-148871/load-common-constant
2 parents b4068b3 + 9668d26 commit ebd1c28

171 files changed

Lines changed: 4789 additions & 2604 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.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/c-api/concrete.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Other Objects
112112
picklebuffer.rst
113113
weakref.rst
114114
capsule.rst
115+
sentinel.rst
115116
frame.rst
116117
gen.rst
117118
coro.rst

Doc/c-api/sentinel.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.. highlight:: c
2+
3+
.. _sentinelobjects:
4+
5+
Sentinel objects
6+
----------------
7+
8+
.. c:var:: PyTypeObject PySentinel_Type
9+
10+
This instance of :c:type:`PyTypeObject` represents the Python
11+
:class:`sentinel` type. This is the same object as :class:`sentinel`.
12+
13+
.. versionadded:: next
14+
15+
.. c:function:: int PySentinel_Check(PyObject *o)
16+
17+
Return true if *o* is a :class:`sentinel` object. The :class:`sentinel` type
18+
does not allow subclasses, so this check is exact.
19+
20+
.. versionadded:: next
21+
22+
.. c:function:: PyObject* PySentinel_New(const char *name, const char *module_name)
23+
24+
Return a new :class:`sentinel` object with :attr:`~sentinel.__name__` set to
25+
*name* and :attr:`~sentinel.__module__` set to *module_name*.
26+
*name* must not be ``NULL``. If *module_name* is ``NULL``, :attr:`~sentinel.__module__`
27+
is set to ``None``.
28+
Return ``NULL`` with an exception set on failure.
29+
30+
For pickling to work, *module_name* must be the name of an importable
31+
module, and the sentinel must be accessible from that module under a
32+
path matching *name*. Pickle treats *name* as a global variable name
33+
in *module_name* (see :meth:`object.__reduce__`).
34+
35+
.. versionadded:: next

Doc/data/refcounts.dat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,6 +2037,10 @@ PySeqIter_Check:PyObject *:op:0:
20372037
PySeqIter_New:PyObject*::+1:
20382038
PySeqIter_New:PyObject*:seq:0:
20392039

2040+
PySentinel_New:PyObject*::+1:
2041+
PySentinel_New:const char*:name::
2042+
PySentinel_New:const char*:module_name::
2043+
20402044
PySequence_Check:int:::
20412045
PySequence_Check:PyObject*:o:0:
20422046

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/library/faulthandler.rst

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ tracebacks:
3131
* Each string is limited to 500 characters.
3232
* Only the filename, the function name and the line number are
3333
displayed. (no source code)
34-
* It is limited to 100 frames and 100 threads.
34+
* It is limited to 100 frames per thread, and 100 threads
35+
(configurable via *max_threads*).
3536
* The order is reversed: the most recent call is shown first.
3637

3738
By default, the Python traceback is written to :data:`sys.stderr`. To see
@@ -55,16 +56,20 @@ at Python startup.
5556
Dumping the traceback
5657
---------------------
5758

58-
.. function:: dump_traceback(file=sys.stderr, all_threads=True)
59+
.. function:: dump_traceback(file=sys.stderr, all_threads=True, *, max_threads=100)
5960

6061
Dump the tracebacks of all threads into *file*. If *all_threads* is
61-
``False``, dump only the current thread.
62+
``False``, dump only the current thread. *max_threads* caps the number
63+
of threads dumped.
6264

6365
.. seealso:: :func:`traceback.print_tb`, which can be used to print a traceback object.
6466

6567
.. versionchanged:: 3.5
6668
Added support for passing file descriptor to this function.
6769

70+
.. versionchanged:: next
71+
Added the *max_threads* keyword argument.
72+
6873

6974
Dumping the C stack
7075
-------------------
@@ -100,7 +105,7 @@ instead of the stack, even if the operating system supports dumping stacks.
100105
Fault handler state
101106
-------------------
102107

103-
.. function:: enable(file=sys.stderr, all_threads=True, c_stack=True)
108+
.. function:: enable(file=sys.stderr, all_threads=True, c_stack=True, *, max_threads=100)
104109

105110
Enable the fault handler: install handlers for the :const:`~signal.SIGSEGV`,
106111
:const:`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal.SIGBUS`
@@ -116,6 +121,8 @@ Fault handler state
116121
traceback, unless the system does not support it. See :func:`dump_c_stack` for
117122
more information on compatibility.
118123

124+
*max_threads* caps the number of threads dumped when a fatal signal fires.
125+
119126
.. versionchanged:: 3.5
120127
Added support for passing file descriptor to this function.
121128

@@ -133,6 +140,9 @@ Fault handler state
133140
.. versionchanged:: 3.14
134141
The dump now displays the C stack trace if *c_stack* is true.
135142

143+
.. versionchanged:: next
144+
Added the *max_threads* keyword argument.
145+
136146
.. function:: disable()
137147

138148
Disable the fault handler: uninstall the signal handlers installed by
@@ -146,15 +156,15 @@ Fault handler state
146156
Dumping the tracebacks after a timeout
147157
--------------------------------------
148158

149-
.. function:: dump_traceback_later(timeout, repeat=False, file=sys.stderr, exit=False)
159+
.. function:: dump_traceback_later(timeout, repeat=False, file=sys.stderr, exit=False, *, max_threads=100)
150160

151161
Dump the tracebacks of all threads, after a timeout of *timeout* seconds, or
152162
every *timeout* seconds if *repeat* is ``True``. If *exit* is ``True``, call
153163
:c:func:`!_exit` with status=1 after dumping the tracebacks. (Note
154164
:c:func:`!_exit` exits the process immediately, which means it doesn't do any
155165
cleanup like flushing file buffers.) If the function is called twice, the new
156166
call replaces previous parameters and resets the timeout. The timer has a
157-
sub-second resolution.
167+
sub-second resolution. *max_threads* caps the number of threads dumped.
158168

159169
The *file* must be kept open until the traceback is dumped or
160170
:func:`cancel_dump_traceback_later` is called: see :ref:`issue with file
@@ -168,6 +178,9 @@ Dumping the tracebacks after a timeout
168178
.. versionchanged:: 3.7
169179
This function is now always available.
170180

181+
.. versionchanged:: next
182+
Added the *max_threads* keyword argument.
183+
171184
.. function:: cancel_dump_traceback_later()
172185

173186
Cancel the last call to :func:`dump_traceback_later`.
@@ -176,11 +189,12 @@ Dumping the tracebacks after a timeout
176189
Dumping the traceback on a user signal
177190
--------------------------------------
178191

179-
.. function:: register(signum, file=sys.stderr, all_threads=True, chain=False)
192+
.. function:: register(signum, file=sys.stderr, all_threads=True, chain=False, *, max_threads=100)
180193

181194
Register a user signal: install a handler for the *signum* signal to dump
182195
the traceback of all threads, or of the current thread if *all_threads* is
183196
``False``, into *file*. Call the previous handler if chain is ``True``.
197+
*max_threads* caps the number of threads dumped.
184198

185199
The *file* must be kept open until the signal is unregistered by
186200
:func:`unregister`: see :ref:`issue with file descriptors <faulthandler-fd>`.
@@ -190,6 +204,9 @@ Dumping the traceback on a user signal
190204
.. versionchanged:: 3.5
191205
Added support for passing file descriptor to this function.
192206

207+
.. versionchanged:: next
208+
Added the *max_threads* keyword argument.
209+
193210
.. function:: unregister(signum)
194211

195212
Unregister a user signal: uninstall the handler of the *signum* signal

0 commit comments

Comments
 (0)