Skip to content

Commit 40e6391

Browse files
Merge branch 'main' into feature-143017
2 parents e1ae625 + 12d363b commit 40e6391

File tree

136 files changed

+5529
-2262
lines changed

Some content is hidden

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

136 files changed

+5529
-2262
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,4 @@ jobs:
2222
- uses: actions/checkout@v4
2323
with:
2424
persist-credentials: false
25-
- uses: actions/setup-python@v5
26-
with:
27-
python-version: "3.x"
28-
- uses: pre-commit/action@v3.0.1
25+
- uses: j178/prek-action@v1

.github/zizmor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Configuration for the zizmor static analysis tool, run via pre-commit in CI
1+
# Configuration for the zizmor static analysis tool, run via prek in CI
22
# https://woodruffw.github.io/zizmor/configuration/
33
rules:
44
dangerous-triggers:

Doc/library/compression.zstd.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Reading and writing compressed files
7373
argument is not None, a :exc:`!TypeError` will be raised.
7474

7575
When writing, the *options* argument can be a dictionary
76-
providing advanced decompression parameters; see
76+
providing advanced compression parameters; see
7777
:class:`CompressionParameter` for detailed information about supported
7878
parameters. The *level* argument is the compression level to use when
7979
writing compressed data. Only one of *level* or *options* may be non-None.
@@ -117,7 +117,7 @@ Reading and writing compressed files
117117
argument is not None, a :exc:`!TypeError` will be raised.
118118

119119
When writing, the *options* argument can be a dictionary
120-
providing advanced decompression parameters; see
120+
providing advanced compression parameters; see
121121
:class:`CompressionParameter` for detailed information about supported
122122
parameters. The *level* argument is the compression level to use when
123123
writing compressed data. Only one of *level* or *options* may be passed. The

Doc/library/concurrent.futures.rst

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ the bytes over a shared :mod:`socket <socket>` or
308308

309309
.. note::
310310
The executor may replace uncaught exceptions from *initializer*
311-
with :class:`~concurrent.futures.interpreter.ExecutionFailed`.
311+
with :class:`~concurrent.interpreters.ExecutionFailed`.
312312

313313
Other caveats from parent :class:`ThreadPoolExecutor` apply here.
314314

@@ -320,11 +320,11 @@ likewise serializes the return value when sending it back.
320320
When a worker's current task raises an uncaught exception, the worker
321321
always tries to preserve the exception as-is. If that is successful
322322
then it also sets the ``__cause__`` to a corresponding
323-
:class:`~concurrent.futures.interpreter.ExecutionFailed`
323+
:class:`~concurrent.interpreters.ExecutionFailed`
324324
instance, which contains a summary of the original exception.
325325
In the uncommon case that the worker is not able to preserve the
326326
original as-is then it directly preserves the corresponding
327-
:class:`~concurrent.futures.interpreter.ExecutionFailed`
327+
:class:`~concurrent.interpreters.ExecutionFailed`
328328
instance instead.
329329

330330

@@ -379,6 +379,11 @@ in a REPL or a lambda should not be expected to work.
379379
default in absence of a *mp_context* parameter. This feature is incompatible
380380
with the "fork" start method.
381381

382+
.. note::
383+
Bugs have been reported when using the *max_tasks_per_child* feature that
384+
can result in the :class:`ProcessPoolExecutor` hanging in some
385+
circumstances. Follow its eventual resolution in :gh:`115634`.
386+
382387
.. versionchanged:: 3.3
383388
When one of the worker processes terminates abruptly, a
384389
:exc:`~concurrent.futures.process.BrokenProcessPool` error is now raised.
@@ -715,15 +720,6 @@ Exception classes
715720

716721
.. versionadded:: 3.14
717722

718-
.. exception:: ExecutionFailed
719-
720-
Raised from :class:`~concurrent.futures.InterpreterPoolExecutor` when
721-
the given initializer fails or from
722-
:meth:`~concurrent.futures.Executor.submit` when there's an uncaught
723-
exception from the submitted task.
724-
725-
.. versionadded:: 3.14
726-
727723
.. currentmodule:: concurrent.futures.process
728724

729725
.. exception:: BrokenProcessPool

Doc/library/importlib.metadata.rst

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,16 @@ Distributions
418418
equal, even if they relate to the same installed distribution and
419419
accordingly have the same attributes.
420420

421+
.. method:: discover(cls, *, context=None, **kwargs)
422+
423+
Returns an iterable of :class:`Distribution` instances for all packages.
424+
425+
The optional argument *context* is a :class:`DistributionFinder.Context`
426+
instance, used to modify the search for distributions. Alternatively,
427+
*kwargs* may contain keyword arguments for constructing a new
428+
:class:`!DistributionFinder.Context`.
429+
430+
421431
While the module level API described above is the most common and convenient usage,
422432
you can get all of that information from the :class:`!Distribution` class.
423433
:class:`!Distribution` is an abstract object that represents the metadata for
@@ -466,6 +476,61 @@ This metadata finder search defaults to ``sys.path``, but varies slightly in how
466476
- ``importlib.metadata`` does not honor :class:`bytes` objects on ``sys.path``.
467477
- ``importlib.metadata`` will incidentally honor :py:class:`pathlib.Path` objects on ``sys.path`` even though such values will be ignored for imports.
468478

479+
.. class:: DistributionFinder
480+
481+
A :class:`~importlib.abc.MetaPathFinder` subclass capable of discovering
482+
installed distributions.
483+
484+
Custom providers should implement this interface in order to
485+
supply metadata.
486+
487+
.. class:: Context(**kwargs)
488+
489+
A :class:`!Context` gives a custom provider a means to
490+
solicit additional details from the callers of distribution discovery
491+
functions like :func:`distributions` or :meth:`Distribution.discover`
492+
beyond :attr:`!.name` and :attr:`!.path` when searching
493+
for distributions.
494+
495+
For example, a provider could expose suites of packages in either a
496+
"public" or "private" ``realm``. A caller of distribution discovery
497+
functions may wish to query only for distributions in a particular realm
498+
and could call ``distributions(realm="private")`` to signal to the
499+
custom provider to only include distributions from that
500+
realm.
501+
502+
Each :class:`!DistributionFinder` must expect any parameters and should
503+
attempt to honor the canonical parameters defined below when
504+
appropriate.
505+
506+
See the section on :ref:`implementing-custom-providers` for more details.
507+
508+
.. attribute:: name
509+
510+
Specific name for which a distribution finder should match.
511+
512+
A :attr:`!.name` of ``None`` matches all distributions.
513+
514+
.. attribute:: path
515+
516+
A property providing the sequence of directory paths that a
517+
distribution finder should search.
518+
519+
Typically refers to Python installed package paths such as
520+
"site-packages" directories and defaults to :attr:`sys.path`.
521+
522+
523+
.. function:: distributions(**kwargs)
524+
525+
Returns an iterable of :class:`Distribution` instances for all packages.
526+
527+
The *kwargs* argument may contain either a keyword argument ``context``, a
528+
:class:`DistributionFinder.Context` instance, or pass keyword arguments for
529+
constructing a new :class:`!DistributionFinder.Context`. The
530+
:class:`!DistributionFinder.Context` is used to modify the search for
531+
distributions.
532+
533+
.. _implementing-custom-providers:
469534

470535
Implementing Custom Providers
471536
=============================
@@ -493,7 +558,7 @@ interface expected of finders by Python's import system.
493558
``importlib.metadata`` extends this protocol by looking for an optional
494559
``find_distributions`` callable on the finders from
495560
:data:`sys.meta_path` and presents this extended interface as the
496-
``DistributionFinder`` abstract base class, which defines this abstract
561+
:class:`DistributionFinder` abstract base class, which defines this abstract
497562
method::
498563

499564
@abc.abstractmethod
@@ -502,9 +567,11 @@ method::
502567
loading the metadata for packages for the indicated ``context``.
503568
"""
504569

505-
The ``DistributionFinder.Context`` object provides ``.path`` and ``.name``
506-
properties indicating the path to search and name to match and may
507-
supply other relevant context sought by the consumer.
570+
The :class:`DistributionFinder.Context` object provides
571+
:attr:`~DistributionFinder.Context.path` and
572+
:attr:`~DistributionFinder.Context.name` properties indicating the path to
573+
search and name to match and may supply other relevant context sought by the
574+
consumer.
508575

509576
In practice, to support finding distribution package
510577
metadata in locations other than the file system, subclass
@@ -529,7 +596,7 @@ Imagine a custom finder that loads Python modules from a database::
529596
That importer now presumably provides importable modules from a
530597
database, but it provides no metadata or entry points. For this
531598
custom importer to provide metadata, it would also need to implement
532-
``DistributionFinder``::
599+
:class:`DistributionFinder`::
533600

534601
from importlib.metadata import DistributionFinder
535602

Doc/library/inspect.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
273273
+-----------------+-------------------+---------------------------+
274274
| | ag_running | is the generator running? |
275275
+-----------------+-------------------+---------------------------+
276+
| | ag_suspended | is the generator |
277+
| | | suspended? |
278+
+-----------------+-------------------+---------------------------+
276279
| | ag_code | code |
277280
+-----------------+-------------------+---------------------------+
278281
| coroutine | __name__ | name |
@@ -286,6 +289,9 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
286289
+-----------------+-------------------+---------------------------+
287290
| | cr_running | is the coroutine running? |
288291
+-----------------+-------------------+---------------------------+
292+
| | cr_suspended | is the coroutine |
293+
| | | suspended? |
294+
+-----------------+-------------------+---------------------------+
289295
| | cr_code | code |
290296
+-----------------+-------------------+---------------------------+
291297
| | cr_origin | where coroutine was |
@@ -319,6 +325,18 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
319325

320326
Add ``__builtins__`` attribute to functions.
321327

328+
.. versionchanged:: 3.11
329+
330+
Add ``gi_suspended`` attribute to generators.
331+
332+
.. versionchanged:: 3.11
333+
334+
Add ``cr_suspended`` attribute to coroutines.
335+
336+
.. versionchanged:: 3.12
337+
338+
Add ``ag_suspended`` attribute to async generators.
339+
322340
.. versionchanged:: 3.14
323341

324342
Add ``f_generator`` attribute to frames.

Doc/library/multiprocessing.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,11 +1693,14 @@ inherited by child processes.
16931693
value is actually a synchronized wrapper for the array.
16941694

16951695
*typecode_or_type* determines the type of the elements of the returned array:
1696-
it is either a ctypes type or a one character typecode of the kind used by
1697-
the :mod:`array` module. If *size_or_initializer* is an integer, then it
1698-
determines the length of the array, and the array will be initially zeroed.
1699-
Otherwise, *size_or_initializer* is a sequence which is used to initialize
1700-
the array and whose length determines the length of the array.
1696+
it is either a :ref:`ctypes type <ctypes-fundamental-data-types>` or a one
1697+
character typecode of the kind used by the :mod:`array` module with the
1698+
exception of ``'w'``, which is not supported. In addition, the ``'c'``
1699+
typecode is an alias for :class:`ctypes.c_char`. If *size_or_initializer*
1700+
is an integer, then it determines the length of the array, and the array
1701+
will be initially zeroed. Otherwise, *size_or_initializer* is a sequence
1702+
which is used to initialize the array and whose length determines the length
1703+
of the array.
17011704

17021705
If *lock* is ``True`` (the default) then a new lock object is created to
17031706
synchronize access to the value. If *lock* is a :class:`Lock` or

Doc/library/profiling.sampling.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,9 @@ interesting functions that highlights:
878878

879879
Use :option:`--no-summary` to suppress both the legend and summary sections.
880880

881-
To save pstats output to a file instead of stdout::
881+
To save pstats output to a binary file instead of stdout::
882882

883-
python -m profiling.sampling run -o profile.txt script.py
883+
python -m profiling.sampling run -o profile.pstats script.py
884884

885885
The pstats format supports several options for controlling the display.
886886
The :option:`--sort` option determines the column used for ordering results::
@@ -1455,7 +1455,9 @@ Output options
14551455

14561456
.. option:: --pstats
14571457

1458-
Generate text statistics output. This is the default.
1458+
Generate pstats statistics. This is the default.
1459+
When written to stdout, the output is a text table; with :option:`-o`,
1460+
it is a binary pstats file.
14591461

14601462
.. option:: --collapsed
14611463

@@ -1486,10 +1488,18 @@ Output options
14861488
.. option:: -o <path>, --output <path>
14871489

14881490
Output file or directory path. Default behavior varies by format:
1489-
:option:`--pstats` writes to stdout, while other formats generate a file
1490-
named ``<format>_<PID>.<ext>`` (for example, ``flamegraph_12345.html``).
1491+
:option:`--pstats` prints a text table to stdout, while ``-o`` writes a
1492+
binary pstats file. Other formats generate a file named
1493+
``<format>_<PID>.<ext>`` (for example, ``flamegraph_12345.html``).
14911494
:option:`--heatmap` creates a directory named ``heatmap_<PID>``.
14921495

1496+
.. option:: --browser
1497+
1498+
Automatically open HTML output (:option:`--flamegraph` and
1499+
:option:`--heatmap`) in your default web browser after generation.
1500+
When profiling with :option:`--subprocesses`, only the main process
1501+
opens the browser; subprocess outputs are never auto-opened.
1502+
14931503

14941504
pstats display options
14951505
----------------------

Doc/library/socket.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,10 +1072,16 @@ The :mod:`socket` module also offers various network-related services:
10721072
a string representing the canonical name of the *host* if
10731073
:const:`AI_CANONNAME` is part of the *flags* argument; else *canonname*
10741074
will be empty. *sockaddr* is a tuple describing a socket address, whose
1075-
format depends on the returned *family* (a ``(address, port)`` 2-tuple for
1076-
:const:`AF_INET`, a ``(address, port, flowinfo, scope_id)`` 4-tuple for
1077-
:const:`AF_INET6`), and is meant to be passed to the :meth:`socket.connect`
1078-
method.
1075+
format depends on the returned *family* and flags Python was compiled with,
1076+
and is meant to be passed to the :meth:`socket.connect` method.
1077+
1078+
*sockaddr* can be one of the following:
1079+
1080+
* a ``(address, port)`` 2-tuple for :const:`AF_INET`
1081+
* a ``(address, port, flowinfo, scope_id)`` 4-tuple for :const:`AF_INET6` if
1082+
Python was compiled with ``--enable-ipv6`` (the default)
1083+
* a 2-tuple containing raw data for :const:`AF_INET6` if Python was
1084+
compiled with ``--disable-ipv6``
10791085

10801086
.. note::
10811087

Doc/library/textwrap.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ functions should be good enough; otherwise, you should use an instance of
102102
print(repr(s)) # prints ' hello\n world\n '
103103
print(repr(dedent(s))) # prints 'hello\n world\n'
104104

105+
.. versionchanged:: 3.14
106+
The :func:`!dedent` function now correctly normalizes blank lines containing
107+
only whitespace characters. Previously, the implementation only normalized
108+
blank lines containing tabs and spaces.
105109

106110
.. function:: indent(text, prefix, predicate=None)
107111

0 commit comments

Comments
 (0)