Skip to content

Commit e420443

Browse files
Merge branch 'main' into fix-referrence-in-functools
2 parents 3265c93 + 2c9a801 commit e420443

File tree

128 files changed

+5456
-1415
lines changed

Some content is hidden

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

128 files changed

+5456
-1415
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Modules/Setup* @erlend-aasland
2626
**/*context* @1st1
2727
**/*genobject* @markshannon
2828
**/*hamt* @1st1
29-
**/*jit* @brandtbucher @savannahostrowski
29+
**/*jit* @brandtbucher @savannahostrowski @diegorusso
30+
Python/perf_jit_trampoline.c # Exclude the owners of "**/*jit*", above.
3031
Objects/set* @rhettinger
3132
Objects/dict* @methane @markshannon
3233
Objects/typevarobject.c @JelleZijlstra

Android/android.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def unpack_deps(host, prefix_dir):
175175
os.chdir(prefix_dir)
176176
deps_url = "https://github.com/beeware/cpython-android-source-deps/releases/download"
177177
for name_ver in ["bzip2-1.0.8-3", "libffi-3.4.4-3", "openssl-3.0.15-4",
178-
"sqlite-3.49.1-0", "xz-5.4.6-1"]:
178+
"sqlite-3.49.1-0", "xz-5.4.6-1", "zstd-1.5.7-1"]:
179179
filename = f"{name_ver}-{host}.tar.gz"
180180
download(f"{deps_url}/{name_ver}/{filename}")
181181
shutil.unpack_archive(filename)

Doc/c-api/exceptions.rst

Lines changed: 187 additions & 251 deletions
Large diffs are not rendered by default.

Doc/conf.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -233,75 +233,6 @@
233233
# Temporary undocumented names.
234234
# In future this list must be empty.
235235
nitpick_ignore += [
236-
# C API: Standard Python exception classes
237-
('c:data', 'PyExc_ArithmeticError'),
238-
('c:data', 'PyExc_AssertionError'),
239-
('c:data', 'PyExc_AttributeError'),
240-
('c:data', 'PyExc_BaseException'),
241-
('c:data', 'PyExc_BaseExceptionGroup'),
242-
('c:data', 'PyExc_BlockingIOError'),
243-
('c:data', 'PyExc_BrokenPipeError'),
244-
('c:data', 'PyExc_BufferError'),
245-
('c:data', 'PyExc_ChildProcessError'),
246-
('c:data', 'PyExc_ConnectionAbortedError'),
247-
('c:data', 'PyExc_ConnectionError'),
248-
('c:data', 'PyExc_ConnectionRefusedError'),
249-
('c:data', 'PyExc_ConnectionResetError'),
250-
('c:data', 'PyExc_EOFError'),
251-
('c:data', 'PyExc_Exception'),
252-
('c:data', 'PyExc_FileExistsError'),
253-
('c:data', 'PyExc_FileNotFoundError'),
254-
('c:data', 'PyExc_FloatingPointError'),
255-
('c:data', 'PyExc_GeneratorExit'),
256-
('c:data', 'PyExc_ImportError'),
257-
('c:data', 'PyExc_IndentationError'),
258-
('c:data', 'PyExc_IndexError'),
259-
('c:data', 'PyExc_InterruptedError'),
260-
('c:data', 'PyExc_IsADirectoryError'),
261-
('c:data', 'PyExc_KeyboardInterrupt'),
262-
('c:data', 'PyExc_KeyError'),
263-
('c:data', 'PyExc_LookupError'),
264-
('c:data', 'PyExc_MemoryError'),
265-
('c:data', 'PyExc_ModuleNotFoundError'),
266-
('c:data', 'PyExc_NameError'),
267-
('c:data', 'PyExc_NotADirectoryError'),
268-
('c:data', 'PyExc_NotImplementedError'),
269-
('c:data', 'PyExc_OSError'),
270-
('c:data', 'PyExc_OverflowError'),
271-
('c:data', 'PyExc_PermissionError'),
272-
('c:data', 'PyExc_ProcessLookupError'),
273-
('c:data', 'PyExc_PythonFinalizationError'),
274-
('c:data', 'PyExc_RecursionError'),
275-
('c:data', 'PyExc_ReferenceError'),
276-
('c:data', 'PyExc_RuntimeError'),
277-
('c:data', 'PyExc_StopAsyncIteration'),
278-
('c:data', 'PyExc_StopIteration'),
279-
('c:data', 'PyExc_SyntaxError'),
280-
('c:data', 'PyExc_SystemError'),
281-
('c:data', 'PyExc_SystemExit'),
282-
('c:data', 'PyExc_TabError'),
283-
('c:data', 'PyExc_TimeoutError'),
284-
('c:data', 'PyExc_TypeError'),
285-
('c:data', 'PyExc_UnboundLocalError'),
286-
('c:data', 'PyExc_UnicodeDecodeError'),
287-
('c:data', 'PyExc_UnicodeEncodeError'),
288-
('c:data', 'PyExc_UnicodeError'),
289-
('c:data', 'PyExc_UnicodeTranslateError'),
290-
('c:data', 'PyExc_ValueError'),
291-
('c:data', 'PyExc_ZeroDivisionError'),
292-
# C API: Standard Python warning classes
293-
('c:data', 'PyExc_BytesWarning'),
294-
('c:data', 'PyExc_DeprecationWarning'),
295-
('c:data', 'PyExc_EncodingWarning'),
296-
('c:data', 'PyExc_FutureWarning'),
297-
('c:data', 'PyExc_ImportWarning'),
298-
('c:data', 'PyExc_PendingDeprecationWarning'),
299-
('c:data', 'PyExc_ResourceWarning'),
300-
('c:data', 'PyExc_RuntimeWarning'),
301-
('c:data', 'PyExc_SyntaxWarning'),
302-
('c:data', 'PyExc_UnicodeWarning'),
303-
('c:data', 'PyExc_UserWarning'),
304-
('c:data', 'PyExc_Warning'),
305236
# Undocumented public C macros
306237
('c:macro', 'Py_BUILD_ASSERT'),
307238
('c:macro', 'Py_BUILD_ASSERT_EXPR'),

Doc/glossary.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,16 @@ Glossary
12801280
and ending with double underscores. Special methods are documented in
12811281
:ref:`specialnames`.
12821282

1283+
standard library
1284+
The collection of :term:`packages <package>`, :term:`modules <module>`
1285+
and :term:`extension modules <extension module>` distributed as a part
1286+
of the official Python interpreter package. The exact membership of the
1287+
collection may vary based on platform, available system libraries, or
1288+
other criteria. Documentation can be found at :ref:`library-index`.
1289+
1290+
See also :data:`sys.stdlib_module_names` for a list of all possible
1291+
standard library module names.
1292+
12831293
statement
12841294
A statement is part of a suite (a "block" of code). A statement is either
12851295
an :term:`expression` or one of several constructs with a keyword, such
@@ -1290,6 +1300,9 @@ Glossary
12901300
issues such as incorrect types. See also :term:`type hints <type hint>`
12911301
and the :mod:`typing` module.
12921302

1303+
stdlib
1304+
An abbreviation of :term:`standard library`.
1305+
12931306
strong reference
12941307
In Python's C API, a strong reference is a reference to an object
12951308
which is owned by the code holding the reference. The strong

Doc/howto/logging-cookbook.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4140,6 +4140,42 @@ The script, when run, prints something like:
41404140
2025-07-02 13:54:47,234 DEBUG fool me ...
41414141
2025-07-02 13:54:47,234 DEBUG can't get fooled again
41424142
4143+
If, on the other hand, you are concerned about `log injection
4144+
<https://owasp.org/www-community/attacks/Log_Injection>`_, you can use a
4145+
formatter which escapes newlines, as per the following example:
4146+
4147+
.. code-block:: python
4148+
4149+
import logging
4150+
4151+
logger = logging.getLogger(__name__)
4152+
4153+
class EscapingFormatter(logging.Formatter):
4154+
def format(self, record):
4155+
s = super().format(record)
4156+
return s.replace('\n', r'\n')
4157+
4158+
if __name__ == '__main__':
4159+
h = logging.StreamHandler()
4160+
h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s %(message)s'))
4161+
logging.basicConfig(level=logging.DEBUG, handlers = [h])
4162+
logger.debug('Single line')
4163+
logger.debug('Multiple lines:\nfool me once ...')
4164+
logger.debug('Another single line')
4165+
logger.debug('Multiple lines:\n%s', 'fool me ...\ncan\'t get fooled again')
4166+
4167+
You can, of course, use whatever escaping scheme makes the most sense for you.
4168+
The script, when run, should produce output like this:
4169+
4170+
.. code-block:: text
4171+
4172+
2025-07-09 06:47:33,783 DEBUG Single line
4173+
2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me once ...
4174+
2025-07-09 06:47:33,783 DEBUG Another single line
4175+
2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me ...\ncan't get fooled again
4176+
4177+
Escaping behaviour can't be the stdlib default , as it would break backwards
4178+
compatibility.
41434179

41444180
.. patterns-to-avoid:
41454181

Doc/library/codecs.rst

Lines changed: 83 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ wider range of codecs when working with binary files:
243243
.. function:: iterencode(iterator, encoding, errors='strict', **kwargs)
244244

245245
Uses an incremental encoder to iteratively encode the input provided by
246-
*iterator*. This function is a :term:`generator`.
247-
The *errors* argument (as well as any
246+
*iterator*. *iterator* must yield :class:`str` objects.
247+
This function is a :term:`generator`. The *errors* argument (as well as any
248248
other keyword argument) is passed through to the incremental encoder.
249249

250250
This function requires that the codec accept text :class:`str` objects
@@ -255,8 +255,8 @@ wider range of codecs when working with binary files:
255255
.. function:: iterdecode(iterator, encoding, errors='strict', **kwargs)
256256

257257
Uses an incremental decoder to iteratively decode the input provided by
258-
*iterator*. This function is a :term:`generator`.
259-
The *errors* argument (as well as any
258+
*iterator*. *iterator* must yield :class:`bytes` objects.
259+
This function is a :term:`generator`. The *errors* argument (as well as any
260260
other keyword argument) is passed through to the incremental decoder.
261261

262262
This function requires that the codec accept :class:`bytes` objects
@@ -265,6 +265,20 @@ wider range of codecs when working with binary files:
265265
:func:`iterencode`.
266266

267267

268+
.. function:: readbuffer_encode(buffer, errors=None, /)
269+
270+
Return a :class:`tuple` containing the raw bytes of *buffer*, a
271+
:ref:`buffer-compatible object <bufferobjects>` or :class:`str`
272+
(encoded to UTF-8 before processing), and their length in bytes.
273+
274+
The *errors* argument is ignored.
275+
276+
.. code-block:: pycon
277+
278+
>>> codecs.readbuffer_encode(b"Zito")
279+
(b'Zito', 4)
280+
281+
268282
The module also provides the following constants which are useful for reading
269283
and writing to platform dependent files:
270284

@@ -1381,7 +1395,11 @@ encodings.
13811395
| | | It is used in the Python |
13821396
| | | pickle protocol. |
13831397
+--------------------+---------+---------------------------+
1384-
| undefined | | Raise an exception for |
1398+
| undefined | | This Codec should only |
1399+
| | | be used for testing |
1400+
| | | purposes. |
1401+
| | | |
1402+
| | | Raise an exception for |
13851403
| | | all conversions, even |
13861404
| | | empty strings. The error |
13871405
| | | handler is ignored. |
@@ -1484,6 +1502,66 @@ mapping. It is not supported by :meth:`str.encode` (which only produces
14841502
Restoration of the ``rot13`` alias.
14851503

14861504

1505+
:mod:`encodings` --- Encodings package
1506+
--------------------------------------
1507+
1508+
.. module:: encodings
1509+
:synopsis: Encodings package
1510+
1511+
This module implements the following functions:
1512+
1513+
.. function:: normalize_encoding(encoding)
1514+
1515+
Normalize encoding name *encoding*.
1516+
1517+
Normalization works as follows: all non-alphanumeric characters except the
1518+
dot used for Python package names are collapsed and replaced with a single
1519+
underscore, leading and trailing underscores are removed.
1520+
For example, ``' -;#'`` becomes ``'_'``.
1521+
1522+
Note that *encoding* should be ASCII only.
1523+
1524+
1525+
.. note::
1526+
The following functions should not be used directly, except for testing
1527+
purposes; :func:`codecs.lookup` should be used instead.
1528+
1529+
1530+
.. function:: search_function(encoding)
1531+
1532+
Search for the codec module corresponding to the given encoding name
1533+
*encoding*.
1534+
1535+
This function first normalizes the *encoding* using
1536+
:func:`normalize_encoding`, then looks for a corresponding alias.
1537+
It attempts to import a codec module from the encodings package using either
1538+
the alias or the normalized name. If the module is found and defines a valid
1539+
``getregentry()`` function that returns a :class:`codecs.CodecInfo` object,
1540+
the codec is cached and returned.
1541+
1542+
If the codec module defines a ``getaliases()`` function any returned aliases
1543+
are registered for future use.
1544+
1545+
1546+
.. function:: win32_code_page_search_function(encoding)
1547+
1548+
Search for a Windows code page encoding *encoding* of the form ``cpXXXX``.
1549+
1550+
If the code page is valid and supported, return a :class:`codecs.CodecInfo`
1551+
object for it.
1552+
1553+
.. availability:: Windows.
1554+
1555+
.. versionadded:: 3.14
1556+
1557+
1558+
This module implements the following exception:
1559+
1560+
.. exception:: CodecRegistryError
1561+
1562+
Raised when a codec is invalid or incompatible.
1563+
1564+
14871565
:mod:`encodings.idna` --- Internationalized Domain Names in Applications
14881566
------------------------------------------------------------------------
14891567

Doc/library/email.parser.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ methods.
4848
FeedParser API
4949
^^^^^^^^^^^^^^
5050

51-
The :class:`BytesFeedParser`, imported from the :mod:`email.feedparser` module,
52-
provides an API that is conducive to incremental parsing of email messages,
51+
The :class:`BytesFeedParser`, imported from the :mod:`email.parser.FeedParser`
52+
module, provides an API that is conducive to incremental parsing of email messages,
5353
such as would be necessary when reading the text of an email message from a
5454
source that can block (such as a socket). The :class:`BytesFeedParser` can of
5555
course be used to parse an email message fully contained in a :term:`bytes-like
@@ -116,7 +116,7 @@ Here is the API for the :class:`BytesFeedParser`:
116116
Works like :class:`BytesFeedParser` except that the input to the
117117
:meth:`~BytesFeedParser.feed` method must be a string. This is of limited
118118
utility, since the only way for such a message to be valid is for it to
119-
contain only ASCII text or, if :attr:`~email.policy.Policy.utf8` is
119+
contain only ASCII text or, if :attr:`~email.policy.EmailPolicy.utf8` is
120120
``True``, no binary attachments.
121121

122122
.. versionchanged:: 3.3 Added the *policy* keyword.
@@ -155,11 +155,11 @@ message body, instead setting the payload to the raw body.
155155

156156
Read all the data from the binary file-like object *fp*, parse the
157157
resulting bytes, and return the message object. *fp* must support
158-
both the :meth:`~io.IOBase.readline` and the :meth:`~io.IOBase.read`
158+
both the :meth:`~io.IOBase.readline` and the :meth:`~io.TextIOBase.read`
159159
methods.
160160

161161
The bytes contained in *fp* must be formatted as a block of :rfc:`5322`
162-
(or, if :attr:`~email.policy.Policy.utf8` is ``True``, :rfc:`6532`)
162+
(or, if :attr:`~email.policy.EmailPolicy.utf8` is ``True``, :rfc:`6532`)
163163
style headers and header continuation lines, optionally preceded by an
164164
envelope header. The header block is terminated either by the end of the
165165
data or by a blank line. Following the header block is the body of the

Doc/library/os.path.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,10 @@ the :mod:`glob` module.)
298298
device than *path*, or whether :file:`{path}/..` and *path* point to the same
299299
i-node on the same device --- this should detect mount points for all Unix
300300
and POSIX variants. It is not able to reliably detect bind mounts on the
301-
same filesystem. On Windows, a drive letter root and a share UNC are
302-
always mount points, and for any other path ``GetVolumePathName`` is called
303-
to see if it is different from the input path.
301+
same filesystem. On Linux systems, it will always return ``True`` for btrfs
302+
subvolumes, even if they aren't mount points. On Windows, a drive letter root
303+
and a share UNC are always mount points, and for any other path
304+
``GetVolumePathName`` is called to see if it is different from the input path.
304305

305306
.. versionchanged:: 3.4
306307
Added support for detecting non-root mount points on Windows.

0 commit comments

Comments
 (0)