Skip to content

Commit f385b1f

Browse files
Merge remote-tracking branch 'upstream/main' into call_function_ex_py
2 parents 0b7ac0a + 51227b6 commit f385b1f

File tree

64 files changed

+2746
-1583
lines changed

Some content is hidden

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

64 files changed

+2746
-1583
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,6 @@ jobs:
691691
- build-ubuntu
692692
- build-ubuntu-ssltests-awslc
693693
- build-ubuntu-ssltests-openssl
694-
- build-android
695694
- build-ios
696695
- build-wasi
697696
- test-hypothesis
@@ -706,6 +705,7 @@ jobs:
706705
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
707706
with:
708707
allowed-failures: >-
708+
build-android,
709709
build-windows-msi,
710710
build-ubuntu-ssltests-awslc,
711711
build-ubuntu-ssltests-openssl,

Doc/deprecations/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Deprecations
77

88
.. include:: pending-removal-in-3.17.rst
99

10+
.. include:: pending-removal-in-3.18.rst
11+
1012
.. include:: pending-removal-in-3.19.rst
1113

1214
.. include:: pending-removal-in-3.20.rst
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Pending removal in Python 3.18
2+
------------------------------
3+
4+
* :mod:`decimal`:
5+
6+
* The non-standard and undocumented :class:`~decimal.Decimal` format
7+
specifier ``'N'``, which is only supported in the :mod:`!decimal` module's
8+
C implementation, has been deprecated since Python 3.13.
9+
(Contributed by Serhiy Storchaka in :gh:`89902`.)

Doc/library/argparse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ upper-cased name. For example::
753753

754754
>>> parser = argparse.ArgumentParser(prog='PROG')
755755
>>> parser.add_argument('--foo-bar')
756-
>>> parser.parse_args(['--foo-bar', 'FOO-BAR']
756+
>>> parser.parse_args(['--foo-bar', 'FOO-BAR'])
757757
Namespace(foo_bar='FOO-BAR')
758758
>>> parser.print_help()
759759
usage: [-h] [--foo-bar FOO-BAR]

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/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/os.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,15 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
15561556
.. versionadded:: 3.15
15571557

15581558

1559+
.. data:: RWF_ATOMIC
1560+
1561+
Write data atomically. Requires alignment to the device's atomic write unit.
1562+
1563+
.. availability:: Linux >= 6.11
1564+
1565+
.. versionadded:: next
1566+
1567+
15591568
.. function:: ptsname(fd, /)
15601569

15611570
Return the name of the slave pseudo-terminal device associated with the
@@ -1598,6 +1607,7 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo
15981607
- :data:`RWF_SYNC`
15991608
- :data:`RWF_APPEND`
16001609
- :data:`RWF_DONTCACHE`
1610+
- :data:`RWF_ATOMIC`
16011611

16021612
Return the total number of bytes actually written.
16031613

@@ -1969,7 +1979,8 @@ can be inherited by child processes. Since Python 3.4, file descriptors
19691979
created by Python are non-inheritable by default.
19701980

19711981
On UNIX, non-inheritable file descriptors are closed in child processes at the
1972-
execution of a new program, other file descriptors are inherited.
1982+
execution of a new program, other file descriptors are inherited. Note that
1983+
non-inheritable file descriptors are still *inherited* by child processes on :func:`os.fork`.
19731984

19741985
On Windows, non-inheritable handles and file descriptors are closed in child
19751986
processes, except for standard streams (file descriptors 0, 1 and 2: stdin, stdout

Doc/library/stdtypes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,6 +2190,15 @@ expression support in the :mod:`re` module).
21902190
Nonprintable characters are those in group Separator or Other (Z or C),
21912191
except the ASCII space.
21922192

2193+
For example:
2194+
2195+
.. doctest::
2196+
2197+
>>> ''.isprintable(), ' '.isprintable()
2198+
(True, True)
2199+
>>> '\t'.isprintable(), '\n'.isprintable()
2200+
(False, False)
2201+
21932202

21942203
.. method:: str.isspace()
21952204

Doc/library/tempfile.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ The module defines the following user-callable items:
225225
properly implements the :const:`os.O_EXCL` flag for :func:`os.open`. The
226226
file is readable and writable only by the creating user ID. If the
227227
platform uses permission bits to indicate whether a file is executable,
228-
the file is executable by no one. The file descriptor is not inherited
229-
by child processes.
228+
the file is executable by no one.
229+
230+
The file descriptor is :ref:`not inherited by child processes <fd_inheritance>`.
230231

231232
Unlike :func:`TemporaryFile`, the user of :func:`mkstemp` is responsible
232233
for deleting the temporary file when done with it.

Doc/reference/datamodel.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,7 @@ Notes on using *__slots__*:
26172617
* :exc:`TypeError` will be raised if *__slots__* other than *__dict__* and
26182618
*__weakref__* are defined for a class derived from a
26192619
:c:member:`"variable-length" built-in type <PyTypeObject.tp_itemsize>` such as
2620-
:class:`int`, :class:`bytes`, and :class:`tuple`.
2620+
:class:`int`, :class:`bytes`, and :class:`type`, except :class:`tuple`.
26212621

26222622
* Any non-string :term:`iterable` may be assigned to *__slots__*.
26232623

@@ -2642,6 +2642,7 @@ Notes on using *__slots__*:
26422642

26432643
.. versionchanged:: 3.15
26442644
Allowed defining the *__dict__* and *__weakref__* *__slots__* for any class.
2645+
Allowed defining any *__slots__* for a class derived from :class:`tuple`.
26452646

26462647

26472648
.. _class-customization:

0 commit comments

Comments
 (0)