Skip to content

Commit dfbd0c2

Browse files
committed
Merge branch 'main' of https://github.com/python/cpython into manjusaka/to-bool-str
2 parents a0895de + dd750b3 commit dfbd0c2

26 files changed

+322
-41
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/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/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:

Doc/whatsnew/3.13.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,7 @@ New Deprecations
18611861
* Deprecate the non-standard and undocumented :class:`~decimal.Decimal`
18621862
format specifier ``'N'``,
18631863
which is only supported in the :mod:`!decimal` module's C implementation.
1864+
Scheduled to be removed in Python 3.18.
18641865
(Contributed by Serhiy Storchaka in :gh:`89902`.)
18651866

18661867
* :mod:`dis`:
@@ -2024,6 +2025,8 @@ New Deprecations
20242025

20252026
.. include:: ../deprecations/pending-removal-in-3.17.rst
20262027

2028+
.. include:: ../deprecations/pending-removal-in-3.18.rst
2029+
20272030
.. include:: ../deprecations/pending-removal-in-3.19.rst
20282031

20292032
.. include:: ../deprecations/pending-removal-in-3.20.rst

Doc/whatsnew/3.14.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,6 +2718,8 @@ New deprecations
27182718

27192719
.. include:: ../deprecations/pending-removal-in-3.17.rst
27202720

2721+
.. include:: ../deprecations/pending-removal-in-3.18.rst
2722+
27212723
.. include:: ../deprecations/pending-removal-in-3.19.rst
27222724

27232725
.. include:: ../deprecations/pending-removal-in-3.20.rst

Doc/whatsnew/3.15.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ Other language changes
398398
for any class.
399399
(Contributed by Serhiy Storchaka in :gh:`41779`.)
400400

401+
* Allowed defining any :ref:`__slots__ <slots>` for a class derived from
402+
:class:`tuple` (including classes created by :func:`collections.namedtuple`).
403+
(Contributed by Serhiy Storchaka in :gh:`41779`.)
404+
401405

402406
New modules
403407
===========
@@ -1167,6 +1171,8 @@ New deprecations
11671171

11681172
.. include:: ../deprecations/pending-removal-in-3.17.rst
11691173

1174+
.. include:: ../deprecations/pending-removal-in-3.18.rst
1175+
11701176
.. include:: ../deprecations/pending-removal-in-3.19.rst
11711177

11721178
.. include:: ../deprecations/pending-removal-in-3.20.rst
@@ -1412,7 +1418,7 @@ that may require changes to your code.
14121418
:func:`resource.setrlimit` and :func:`resource.prlimit` is now deprecated.
14131419
(Contributed by Serhiy Storchaka in :gh:`137044`.)
14141420

1415-
* :meth:`~mmap.mmap.resize` has been removed on platforms that don't support the
1421+
* :meth:`mmap.mmap.resize` has been removed on platforms that don't support the
14161422
underlying syscall, instead of raising a :exc:`SystemError`.
14171423

14181424
* A resource warning is now emitted for an unclosed

Include/descrobject.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ struct PyMemberDef {
8080
#define _Py_T_NONE 20 // Deprecated. Value is always None.
8181

8282
/* Flags */
83-
#define Py_READONLY 1
84-
#define Py_AUDIT_READ 2 // Added in 3.10, harmless no-op before that
85-
#define _Py_WRITE_RESTRICTED 4 // Deprecated, no-op. Do not reuse the value.
86-
#define Py_RELATIVE_OFFSET 8
83+
#define Py_READONLY (1 << 0)
84+
#define Py_AUDIT_READ (1 << 1) // Added in 3.10, harmless no-op before that
85+
#define _Py_WRITE_RESTRICTED (1 << 2) // Deprecated, no-op. Do not reuse the value.
86+
#define Py_RELATIVE_OFFSET (1 << 3)
87+
88+
#ifndef Py_LIMITED_API
89+
# define _Py_AFTER_ITEMS (1 << 4) // For internal use.
90+
#endif
8791

8892
PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, PyMemberDef *);
8993
PyAPI_FUNC(int) PyMember_SetOne(char *, PyMemberDef *, PyObject *);

0 commit comments

Comments
 (0)