Skip to content

Commit e6a739b

Browse files
authored
Merge branch 'python:main' into 42664-dup-cookie-fix
2 parents 9eed4e0 + 0dfa7ce commit e6a739b

26 files changed

+226
-160
lines changed

Doc/faq/general.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ Python versions are numbered "A.B.C" or "A.B":
133133
changes.
134134
* *C* is the micro version number -- it is incremented for each bugfix release.
135135

136-
See :pep:`6` for more information about bugfix releases.
137-
138136
Not all releases are bugfix releases. In the run-up to a new feature release, a
139137
series of development releases are made, denoted as alpha, beta, or release
140138
candidate. Alphas are early releases in which interfaces aren't yet finalized;
@@ -157,7 +155,11 @@ unreleased versions, built directly from the CPython development repository. In
157155
practice, after a final minor release is made, the version is incremented to the
158156
next minor version, which becomes the "a0" version, e.g. "2.4a0".
159157

160-
See also the documentation for :data:`sys.version`, :data:`sys.hexversion`, and
158+
See the `Developer's Guide
159+
<https://devguide.python.org/developer-workflow/development-cycle/>`__
160+
for more information about the development cycle, and
161+
:pep:`387` to learn more about Python's backward compatibility policy. See also
162+
the documentation for :data:`sys.version`, :data:`sys.hexversion`, and
161163
:data:`sys.version_info`.
162164

163165

Doc/library/asyncio-stream.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ StreamWriter
347347
be resumed. When there is nothing to wait for, the :meth:`drain`
348348
returns immediately.
349349

350-
.. coroutinemethod:: start_tls(sslcontext, \*, server_hostname=None, \
350+
.. coroutinemethod:: start_tls(sslcontext, *, server_hostname=None, \
351351
ssl_handshake_timeout=None, ssl_shutdown_timeout=None)
352352

353353
Upgrade an existing stream-based connection to TLS.

Doc/library/enum.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Data Types
170170
final *enum*, as well as creating the enum members, properly handling
171171
duplicates, providing iteration over the enum class, etc.
172172

173-
.. method:: EnumType.__call__(cls, value, names=None, \*, module=None, qualname=None, type=None, start=1, boundary=None)
173+
.. method:: EnumType.__call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
174174

175175
This method is called in two different ways:
176176

@@ -350,7 +350,7 @@ Data Types
350350
>>> PowersOfThree.SECOND.value
351351
9
352352

353-
.. method:: Enum.__init__(self, \*args, \**kwds)
353+
.. method:: Enum.__init__(self, *args, **kwds)
354354

355355
By default, does nothing. If multiple values are given in the member
356356
assignment, those values become separate arguments to ``__init__``; e.g.
@@ -361,7 +361,7 @@ Data Types
361361

362362
``Weekday.__init__()`` would be called as ``Weekday.__init__(self, 1, 'Mon')``
363363

364-
.. method:: Enum.__init_subclass__(cls, \**kwds)
364+
.. method:: Enum.__init_subclass__(cls, **kwds)
365365

366366
A *classmethod* that is used to further configure subsequent subclasses.
367367
By default, does nothing.
@@ -388,7 +388,7 @@ Data Types
388388
>>> Build('deBUG')
389389
<Build.DEBUG: 'debug'>
390390

391-
.. method:: Enum.__new__(cls, \*args, \**kwds)
391+
.. method:: Enum.__new__(cls, *args, **kwds)
392392

393393
By default, doesn't exist. If specified, either in the enum class
394394
definition or in a mixin class (such as ``int``), all values given

Doc/library/hashlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ More condensed:
121121
Constructors
122122
------------
123123

124-
.. function:: new(name[, data], \*, usedforsecurity=True)
124+
.. function:: new(name[, data], *, usedforsecurity=True)
125125

126126
Is a generic constructor that takes the string *name* of the desired
127127
algorithm as its first parameter. It also exists to allow access to the

Doc/tutorial/introduction.rst

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,6 @@ indexed and sliced::
405405
>>> squares[-3:] # slicing returns a new list
406406
[9, 16, 25]
407407

408-
All slice operations return a new list containing the requested elements. This
409-
means that the following slice returns a
410-
:ref:`shallow copy <shallow_vs_deep_copy>` of the list::
411-
412-
>>> squares[:]
413-
[1, 4, 9, 16, 25]
414-
415408
Lists also support operations like concatenation::
416409

417410
>>> squares + [36, 49, 64, 81, 100]
@@ -435,6 +428,30 @@ the :meth:`!list.append` *method* (we will see more about methods later)::
435428
>>> cubes
436429
[1, 8, 27, 64, 125, 216, 343]
437430

431+
Simple assignment in Python never copies data. When you assign a list
432+
to a variable, the variable refers to the *existing list*.
433+
Any changes you make to the list through one variable will be seen
434+
through all other variables that refer to it.::
435+
436+
>>> rgb = ["Red", "Green", "Blue"]
437+
>>> rgba = rgb
438+
>>> id(rgb) == id(rgba) # they reference the same object
439+
True
440+
>>> rgba.append("Alph")
441+
>>> rgb
442+
["Red", "Green", "Blue", "Alph"]
443+
444+
All slice operations return a new list containing the requested elements. This
445+
means that the following slice returns a
446+
:ref:`shallow copy <shallow_vs_deep_copy>` of the list::
447+
448+
>>> correct_rgba = rgba[:]
449+
>>> correct_rgba[-1] = "Alpha"
450+
>>> correct_rgba
451+
["Red", "Green", "Blue", "Alpha"]
452+
>>> rgba
453+
["Red", "Green", "Blue", "Alph"]
454+
438455
Assignment to slices is also possible, and this can even change the size of the
439456
list or clear it entirely::
440457

Doc/using/configure.rst

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Configure Python
33
****************
44

5+
.. highlight:: sh
6+
57
Build Requirements
68
==================
79

@@ -30,31 +32,31 @@ Features and minimum versions required to build CPython:
3032
* Autoconf 2.71 and aclocal 1.16.4 are required to regenerate the
3133
:file:`configure` script.
3234

33-
.. versionchanged:: 3.13:
34-
Autoconf 2.71, aclocal 1.16.4 and SQLite 3.15.2 are now required.
35+
.. versionchanged:: 3.1
36+
Tcl/Tk version 8.3.1 is now required.
3537

36-
.. versionchanged:: 3.11
37-
C11 compiler, IEEE 754 and NaN support are now required.
38-
On Windows, Visual Studio 2017 or later is required.
39-
Tcl/Tk version 8.5.12 is now required for the :mod:`tkinter` module.
38+
.. versionchanged:: 3.5
39+
On Windows, Visual Studio 2015 or later is now required.
40+
Tcl/Tk version 8.4 is now required.
4041

41-
.. versionchanged:: 3.10
42-
OpenSSL 1.1.1 is now required.
43-
Require SQLite 3.7.15.
42+
.. versionchanged:: 3.6
43+
Selected C99 features are now required, like ``<stdint.h>`` and ``static
44+
inline`` functions.
4445

4546
.. versionchanged:: 3.7
4647
Thread support and OpenSSL 1.0.2 are now required.
4748

48-
.. versionchanged:: 3.6
49-
Selected C99 features are now required, like ``<stdint.h>`` and ``static
50-
inline`` functions.
49+
.. versionchanged:: 3.10
50+
OpenSSL 1.1.1 is now required.
51+
Require SQLite 3.7.15.
5152

52-
.. versionchanged:: 3.5
53-
On Windows, Visual Studio 2015 or later is now required.
54-
Tcl/Tk version 8.4 is now required.
53+
.. versionchanged:: 3.11
54+
C11 compiler, IEEE 754 and NaN support are now required.
55+
On Windows, Visual Studio 2017 or later is required.
56+
Tcl/Tk version 8.5.12 is now required for the :mod:`tkinter` module.
5557

56-
.. versionchanged:: 3.1
57-
Tcl/Tk version 8.3.1 is now required.
58+
.. versionchanged:: 3.13
59+
Autoconf 2.71, aclocal 1.16.4 and SQLite 3.15.2 are now required.
5860

5961
See also :pep:`7` "Style Guide for C Code" and :pep:`11` "CPython platform
6062
support".
@@ -275,7 +277,7 @@ General Options
275277
* to/from free lists;
276278
* dictionary materialized/dematerialized;
277279
* type cache;
278-
* optimization attemps;
280+
* optimization attempts;
279281
* optimization traces created/executed;
280282
* uops executed.
281283

@@ -694,12 +696,12 @@ Debug options
694696

695697
:ref:`Statically allocated objects <static-types>` are not traced.
696698

699+
.. versionadded:: 3.8
700+
697701
.. versionchanged:: 3.13
698702
This build is now ABI compatible with release build and :ref:`debug build
699703
<debug-build>`.
700704

701-
.. versionadded:: 3.8
702-
703705
.. option:: --with-assertions
704706

705707
Build with C assertions enabled (default is no): ``assert(...);`` and
@@ -941,7 +943,9 @@ the version of the cross compiled host Python.
941943

942944
An environment variable that points to a file with configure overrides.
943945

944-
Example *config.site* file::
946+
Example *config.site* file:
947+
948+
.. code-block:: ini
945949
946950
# config.site-aarch64
947951
ac_cv_buggy_getaddrinfo=no
@@ -1019,7 +1023,9 @@ C extensions
10191023

10201024
Some C extensions are built as built-in modules, like the ``sys`` module.
10211025
They are built with the ``Py_BUILD_CORE_BUILTIN`` macro defined.
1022-
Built-in modules have no ``__file__`` attribute::
1026+
Built-in modules have no ``__file__`` attribute:
1027+
1028+
.. code-block:: pycon
10231029
10241030
>>> import sys
10251031
>>> sys
@@ -1031,7 +1037,9 @@ Built-in modules have no ``__file__`` attribute::
10311037
10321038
Other C extensions are built as dynamic libraries, like the ``_asyncio`` module.
10331039
They are built with the ``Py_BUILD_CORE_MODULE`` macro defined.
1034-
Example on Linux x86-64::
1040+
Example on Linux x86-64:
1041+
1042+
.. code-block:: pycon
10351043
10361044
>>> import _asyncio
10371045
>>> _asyncio

Doc/whatsnew/3.13.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,9 @@ Deprecated
791791
coroutine.
792792
(Contributed by Irit Katriel in :gh:`81137`.)
793793

794+
* The undocumented and unused ``tarfile`` attribute of :class:`tarfile.TarFile`
795+
is deprecated and scheduled for removal in Python 3.16.
796+
794797

795798
Pending Removal in Python 3.14
796799
------------------------------

Include/pyexpat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/* note: you must import expat.h before importing this module! */
55

6-
#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.1"
6+
#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.2"
77
#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI"
88

99
struct PyExpat_CAPI

Lib/logging/handlers.py

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -232,19 +232,19 @@ def __init__(self, filename, when='h', interval=1, backupCount=0,
232232
if self.when == 'S':
233233
self.interval = 1 # one second
234234
self.suffix = "%Y-%m-%d_%H-%M-%S"
235-
self.extMatch = r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}(\.\w+)?$"
235+
extMatch = r"(?<!\d)\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}(?!\d)"
236236
elif self.when == 'M':
237237
self.interval = 60 # one minute
238238
self.suffix = "%Y-%m-%d_%H-%M"
239-
self.extMatch = r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}(\.\w+)?$"
239+
extMatch = r"(?<!\d)\d{4}-\d{2}-\d{2}_\d{2}-\d{2}(?!\d)"
240240
elif self.when == 'H':
241241
self.interval = 60 * 60 # one hour
242242
self.suffix = "%Y-%m-%d_%H"
243-
self.extMatch = r"^\d{4}-\d{2}-\d{2}_\d{2}(\.\w+)?$"
243+
extMatch = r"(?<!\d)\d{4}-\d{2}-\d{2}_\d{2}(?!\d)"
244244
elif self.when == 'D' or self.when == 'MIDNIGHT':
245245
self.interval = 60 * 60 * 24 # one day
246246
self.suffix = "%Y-%m-%d"
247-
self.extMatch = r"^\d{4}-\d{2}-\d{2}(\.\w+)?$"
247+
extMatch = r"(?<!\d)\d{4}-\d{2}-\d{2}(?!\d)"
248248
elif self.when.startswith('W'):
249249
self.interval = 60 * 60 * 24 * 7 # one week
250250
if len(self.when) != 2:
@@ -253,11 +253,17 @@ def __init__(self, filename, when='h', interval=1, backupCount=0,
253253
raise ValueError("Invalid day specified for weekly rollover: %s" % self.when)
254254
self.dayOfWeek = int(self.when[1])
255255
self.suffix = "%Y-%m-%d"
256-
self.extMatch = r"^\d{4}-\d{2}-\d{2}(\.\w+)?$"
256+
extMatch = r"(?<!\d)\d{4}-\d{2}-\d{2}(?!\d)"
257257
else:
258258
raise ValueError("Invalid rollover interval specified: %s" % self.when)
259259

260-
self.extMatch = re.compile(self.extMatch, re.ASCII)
260+
# extMatch is a pattern for matching a datetime suffix in a file name.
261+
# After custom naming, it is no longer guaranteed to be separated by
262+
# periods from other parts of the filename. The lookup statements
263+
# (?<!\d) and (?!\d) ensure that the datetime suffix (which itself
264+
# starts and ends with digits) is not preceded or followed by digits.
265+
# This reduces the number of false matches and improves performance.
266+
self.extMatch = re.compile(extMatch, re.ASCII)
261267
self.interval = self.interval * interval # multiply by units requested
262268
# The following line added because the filename passed in could be a
263269
# path object (see Issue #27493), but self.baseFilename will be a string
@@ -376,31 +382,22 @@ def getFilesToDelete(self):
376382
for fileName in fileNames:
377383
if fileName[:plen] == prefix:
378384
suffix = fileName[plen:]
379-
if self.extMatch.match(suffix):
385+
if self.extMatch.fullmatch(suffix):
380386
result.append(os.path.join(dirName, fileName))
381387
else:
382-
# See bpo-44753: Don't use the extension when computing the prefix.
383-
n, e = os.path.splitext(baseName)
384-
prefix = n + '.'
385-
plen = len(prefix)
386388
for fileName in fileNames:
387-
# Our files could be just about anything after custom naming, but
388-
# likely candidates are of the form
389-
# foo.log.DATETIME_SUFFIX or foo.DATETIME_SUFFIX.log
390-
if (not fileName.startswith(baseName) and fileName.endswith(e) and
391-
len(fileName) > (plen + 1) and not fileName[plen+1].isdigit()):
392-
continue
389+
# Our files could be just about anything after custom naming,
390+
# but they should contain the datetime suffix.
391+
# Try to find the datetime suffix in the file name and verify
392+
# that the file name can be generated by this handler.
393+
m = self.extMatch.search(fileName)
394+
while m:
395+
dfn = self.namer(self.baseFilename + "." + m[0])
396+
if os.path.basename(dfn) == fileName:
397+
result.append(os.path.join(dirName, fileName))
398+
break
399+
m = self.extMatch.search(fileName, m.start() + 1)
393400

394-
if fileName[:plen] == prefix:
395-
suffix = fileName[plen:]
396-
# See bpo-45628: The date/time suffix could be anywhere in the
397-
# filename
398-
399-
parts = suffix.split('.')
400-
for part in parts:
401-
if self.extMatch.match(part):
402-
result.append(os.path.join(dirName, fileName))
403-
break
404401
if len(result) < self.backupCount:
405402
result = []
406403
else:

Lib/pathlib/_abc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ def _make_child_direntry(self, entry):
789789
def _make_child_relpath(self, name):
790790
return self.joinpath(name)
791791

792-
def glob(self, pattern, *, case_sensitive=None, follow_symlinks=None):
792+
def glob(self, pattern, *, case_sensitive=None, follow_symlinks=True):
793793
"""Iterate over this subtree and yield all existing files (of any
794794
kind, including directories) matching the given relative pattern.
795795
"""
@@ -846,7 +846,7 @@ def glob(self, pattern, *, case_sensitive=None, follow_symlinks=None):
846846
paths = _select_children(paths, bool(stack), follow_symlinks, match)
847847
return paths
848848

849-
def rglob(self, pattern, *, case_sensitive=None, follow_symlinks=None):
849+
def rglob(self, pattern, *, case_sensitive=None, follow_symlinks=True):
850850
"""Recursively yield all existing files (of any kind, including
851851
directories) matching the given relative pattern, anywhere in
852852
this subtree.

0 commit comments

Comments
 (0)