Skip to content

Commit 25d9a6f

Browse files
authored
Merge branch 'main' into docs/pep750-first-pass
2 parents e562c4e + 35e2c35 commit 25d9a6f

File tree

81 files changed

+1571
-1221
lines changed

Some content is hidden

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

81 files changed

+1571
-1221
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Modules/Setup* @erlend-aasland
2626
**/*context* @1st1
2727
**/*genobject* @markshannon
2828
**/*hamt* @1st1
29-
**/*jit* @brandtbucher @savannahostrowski
29+
**/*jit* @brandtbucher @savannahostrowski @diegorusso
3030
Objects/set* @rhettinger
3131
Objects/dict* @methane @markshannon
3232
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: 18 additions & 4 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

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.

Doc/library/sqlite3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ This section shows recipes for common adapters and converters.
22882288

22892289
def adapt_datetime_iso(val):
22902290
"""Adapt datetime.datetime to timezone-naive ISO 8601 date."""
2291-
return val.isoformat()
2291+
return val.replace(tzinfo=None).isoformat()
22922292

22932293
def adapt_datetime_epoch(val):
22942294
"""Adapt datetime.datetime to Unix timestamp."""

Doc/library/time.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,11 @@ Functions
306306
.. versionadded:: 3.3
307307

308308
.. versionchanged:: 3.5
309-
The function is now always available and always system-wide.
309+
The function is now always available and the clock is now the same for
310+
all processes.
310311

311312
.. versionchanged:: 3.10
312-
On macOS, the function is now system-wide.
313+
On macOS, the clock is now the same for all processes.
313314

314315

315316
.. function:: monotonic_ns() -> int
@@ -325,7 +326,8 @@ Functions
325326

326327
Return the value (in fractional seconds) of a performance counter, i.e. a
327328
clock with the highest available resolution to measure a short duration. It
328-
does include time elapsed during sleep and is system-wide. The reference
329+
does include time elapsed during sleep. The clock is the same for all
330+
processes. The reference
329331
point of the returned value is undefined, so that only the difference between
330332
the results of two calls is valid.
331333

@@ -340,7 +342,7 @@ Functions
340342
.. versionadded:: 3.3
341343

342344
.. versionchanged:: 3.10
343-
On Windows, the function is now system-wide.
345+
On Windows, the clock is now the same for all processes.
344346

345347
.. versionchanged:: 3.13
346348
Use the same clock as :func:`time.monotonic`.
@@ -987,8 +989,8 @@ The following constant is the only parameter that can be sent to
987989

988990
.. data:: CLOCK_REALTIME
989991

990-
System-wide real-time clock. Setting this clock requires appropriate
991-
privileges.
992+
Real-time clock. Setting this clock requires appropriate privileges.
993+
The clock is the same for all processes.
992994

993995
.. availability:: Unix.
994996

0 commit comments

Comments
 (0)