Skip to content

Commit 5cf9acd

Browse files
authored
Merge branch 'main' into port-lazy-modules
2 parents 05934fd + 55f2518 commit 5cf9acd

440 files changed

Lines changed: 9738 additions & 5655 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/reusable-windows.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ permissions:
2222

2323
env:
2424
FORCE_COLOR: 1
25-
IncludeUwp: >-
26-
true
2725

2826
jobs:
2927
build:

.github/workflows/stale.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
uses: actions/stale@b5d41d4e1d5dceea10e7104786b73624c18a190f # v10.2.0
2222
with:
2323
repo-token: ${{ secrets.GITHUB_TOKEN }}
24-
stale-pr-message: 'This PR is stale because it has been open for 30 days with no activity.'
24+
stale-pr-message: 'This PR is stale because it has been open for 90 days with no activity.'
2525
stale-pr-label: 'stale'
2626
days-before-issue-stale: -1
27-
days-before-pr-stale: 30
27+
days-before-pr-stale: 90
2828
days-before-close: -1
2929
ascending: true
3030
operations-per-run: 120

Doc/c-api/import.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,6 @@ Importing Modules
393393
394394
Make all imports lazy by default.
395395
396-
.. c:enumerator:: PyImport_LAZY_NONE
397-
398-
Disable lazy imports entirely. Even explicit ``lazy`` statements become
399-
eager imports.
400-
401396
.. versionadded:: 3.15
402397
403398
.. c:function:: PyObject* PyImport_CreateModuleFromInitfunc(PyObject *spec, PyObject* (*initfunc)(void))

Doc/c-api/sentinel.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ Sentinel objects
3131
3232
.. versionadded:: 3.15
3333
34-
.. c:function:: PyObject* PySentinel_New(const char *name, const char *module_name)
34+
.. c:function:: PyObject* PySentinel_New(const char *name, const char *module_name, const char *repr)
3535
3636
Return a new :class:`sentinel` object with :attr:`~sentinel.__name__` set to
3737
*name* and :attr:`~sentinel.__module__` set to *module_name*.
3838
*name* must not be ``NULL``. If *module_name* is ``NULL``, :attr:`~sentinel.__module__`
39-
is set to ``None``.
39+
is set to ``None``. If *repr* is ``NULL``, ``repr()`` returns :attr:`~sentinel.__name__`.
4040
Return ``NULL`` with an exception set on failure.
4141
4242
For pickling to work, *module_name* must be the name of an importable

Doc/data/refcounts.dat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,6 +2040,7 @@ PySeqIter_New:PyObject*:seq:0:
20402040
PySentinel_New:PyObject*::+1:
20412041
PySentinel_New:const char*:name::
20422042
PySentinel_New:const char*:module_name::
2043+
PySentinel_New:const char*:repr::
20432044

20442045
PySequence_Check:int:::
20452046
PySequence_Check:PyObject*:o:0:

Doc/library/difflib.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -728,18 +728,16 @@ Finally, we compare the two:
728728

729729
>>> from pprint import pprint
730730
>>> pprint(result)
731-
[
732-
' 1. Beautiful is better than ugly.\n',
733-
'- 2. Explicit is better than implicit.\n',
734-
'- 3. Simple is better than complex.\n',
735-
'+ 3. Simple is better than complex.\n',
736-
'? ++\n',
737-
'- 4. Complex is better than complicated.\n',
738-
'? ^ ---- ^\n',
739-
'+ 4. Complicated is better than complex.\n',
740-
'? ++++ ^ ^\n',
741-
'+ 5. Flat is better than nested.\n',
742-
]
731+
[' 1. Beautiful is better than ugly.\n',
732+
'- 2. Explicit is better than implicit.\n',
733+
'- 3. Simple is better than complex.\n',
734+
'+ 3. Simple is better than complex.\n',
735+
'? ++\n',
736+
'- 4. Complex is better than complicated.\n',
737+
'? ^ ---- ^\n',
738+
'+ 4. Complicated is better than complex.\n',
739+
'? ++++ ^ ^\n',
740+
'+ 5. Flat is better than nested.\n']
743741

744742
As a single multi-line string it looks like this:
745743

Doc/library/functions.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,15 +1827,21 @@ are always available. They are listed here in alphabetical order.
18271827
:func:`setattr`.
18281828

18291829

1830-
.. class:: sentinel(name, /)
1830+
.. class:: sentinel(name, /, *, repr=None)
18311831

18321832
Return a new unique sentinel object. *name* must be a :class:`str`, and is
1833-
used as the returned object's representation::
1833+
used by default as the returned object's representation::
18341834

18351835
>>> MISSING = sentinel("MISSING")
18361836
>>> MISSING
18371837
MISSING
18381838

1839+
The optional *repr* argument can be used to specify a different representation::
1840+
1841+
>>> MISSING = sentinel("MISSING", repr="<MISSING>")
1842+
>>> MISSING
1843+
<MISSING>
1844+
18391845
Sentinel objects are truthy and compare equal only to themselves. They are
18401846
intended to be compared with the :keyword:`is` operator.
18411847

@@ -1879,7 +1885,7 @@ are always available. They are listed here in alphabetical order.
18791885

18801886
.. attribute:: __module__
18811887

1882-
The name of the module where the sentinel was created.
1888+
The name of the module where the sentinel was created. This attribute is writable.
18831889

18841890
.. versionadded:: 3.15
18851891

Doc/library/gzip.rst

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Note that additional file formats which can be decompressed by the
2828
The module defines the following items:
2929

3030

31-
.. function:: open(filename, mode='rb', compresslevel=6, encoding=None, errors=None, newline=None)
31+
.. function:: open(filename, mode='rb', compresslevel=6, encoding=None, errors=None, newline=None, *, mtime=None)
3232

3333
Open a gzip-compressed file in binary or text mode, returning a :term:`file
3434
object`.
@@ -43,9 +43,12 @@ The module defines the following items:
4343
The *compresslevel* argument is an integer from 0 to 9, as for the
4444
:class:`GzipFile` constructor.
4545

46+
The keyword-only argument *mtime* represents a Unix timestamp.
47+
4648
For binary mode, this function is equivalent to the :class:`GzipFile`
47-
constructor: ``GzipFile(filename, mode, compresslevel)``. In this case, the
48-
*encoding*, *errors* and *newline* arguments must not be provided.
49+
constructor: ``GzipFile(filename, mode, compresslevel, mtime=mtime)``.
50+
In this case, the *encoding*, *errors* and *newline* arguments must not
51+
be provided.
4952

5053
For text mode, a :class:`GzipFile` object is created, and wrapped in an
5154
:class:`io.TextIOWrapper` instance with the specified encoding, error
@@ -66,6 +69,10 @@ The module defines the following items:
6669
It is the default level used by most compression tools and a better
6770
tradeoff between speed and performance.
6871

72+
.. versionchanged:: next
73+
Added keyword-only argument *mtime* which is passed to the class
74+
constructor of :class:`~gzip.GzipFile`.
75+
6976
.. exception:: BadGzipFile
7077

7178
An exception raised for invalid gzip files. It inherits from :exc:`OSError`.
@@ -108,9 +115,13 @@ The module defines the following items:
108115
is no compression. The default is ``9``.
109116

110117
The optional *mtime* argument is the timestamp requested by gzip. The time
111-
is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970.
112-
If *mtime* is omitted or ``None``, the current time is used. Use *mtime* = 0
113-
to generate a compressed stream that does not depend on creation time.
118+
is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970. Set
119+
*mtime* to ``0`` to generate a compressed stream that does not depend on
120+
creation time. If *mtime* is omitted or ``None``, the current time is used;
121+
however, if the current time is outside the range 00:00:00 UTC, January 1,
122+
1970 through 06:28:15 UTC, February 7, 2106, or explicitly passed *mtime*
123+
argument is outside the range ``0`` to ``2**32-1``, then the value ``0``
124+
is used instead.
114125

115126
See below for the :attr:`mtime` attribute that is set when decompressing.
116127

Doc/library/importlib.metadata.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ You can also get a :ref:`distribution's version number <version>`, list its
105105
current Python environment.
106106

107107

108+
.. exception:: MetadataNotFound
109+
110+
Subclass of :class:`FileNotFoundError` raised when attempting to load metadata
111+
from a distribution folder that is empty or otherwise does not contain a
112+
metadata file.
113+
114+
108115
Functional API
109116
==============
110117

@@ -224,6 +231,9 @@ Distribution metadata
224231
Raises :exc:`PackageNotFoundError` if the named distribution
225232
package is not installed in the current Python environment.
226233

234+
Raises :exc:`MetadataNotFound` if a distribution package is
235+
present but no METADATA file is present.
236+
227237
.. class:: PackageMetadata
228238

229239
A concrete implementation of the
@@ -252,6 +262,12 @@ all the metadata in a JSON-compatible form per :PEP:`566`::
252262
The full set of available metadata is not described here.
253263
See the PyPA `Core metadata specification <https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata>`_ for additional details.
254264

265+
.. versionchanged:: 3.15
266+
Previously and incidentally, if a METADATA file was missing from a distribution, an
267+
empty ``PackageMetadata`` would be returned, indistinguishable from
268+
an empty METADATA file. Now, a missing METADATA file triggers a
269+
``MetadataNotFound`` exception.
270+
255271
.. versionchanged:: 3.10
256272
The ``Description`` is now included in the metadata when presented
257273
through the payload. Line continuation characters have been removed.
@@ -465,6 +481,9 @@ The same applies for :func:`entry_points` and :func:`files`.
465481
.. attribute:: metadata
466482
:type: PackageMetadata
467483

484+
Raises :exc:`MetadataNotFound` if the METADATA file is not present in
485+
the distribution.
486+
468487
There are all kinds of additional metadata available on :class:`!Distribution`
469488
instances as a :class:`PackageMetadata` instance::
470489

Doc/library/os.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,25 @@ process and user.
219219
:data:`os.environ`, and when one of the :meth:`~dict.pop` or
220220
:meth:`~dict.clear` methods is called.
221221

222+
If the :manpage:`clearenv(3)` function is available, the :meth:`~dict.clear` method
223+
uses it and emits a single ``os._clearenv`` audit event. Otherwise, it emits
224+
an ``os.unsetenv`` event on each deleted variable.
225+
226+
.. audit-event:: os.unsetenv key os.unsetenv
227+
228+
.. audit-event:: os._clearenv "" os._clearenv
229+
222230
.. seealso::
223231

224232
The :func:`os.reload_environ` function.
225233

226234
.. versionchanged:: 3.9
227235
Updated to support :pep:`584`'s merge (``|``) and update (``|=``) operators.
228236

237+
.. versionchanged:: 3.15
238+
The :meth:`~dict.clear` method can now emit an ``os._clearenv`` audit
239+
event.
240+
229241

230242
.. data:: environb
231243

0 commit comments

Comments
 (0)