Skip to content

Commit ccebbb4

Browse files
ambvmeta-codesync[bot]
authored andcommitted
Import CPython 3.14.5+ stable branch (2026-06-09)
Summary: Imported python/cpython `3.14.5+` from upstream rev [`51e83ca`](https://www.github.com/python/cpython/commit/51e83ca706d04878e0f6f0bf8030e0dd2f7585a6) (committed 2026-06-09 22:48:25+00:00). # Commit Info - Base: (`3.14.5+`) - [`d56f07c`](https://www.github.com/python/cpython/commit/d56f07c90008170c6eadec226955b3de29e849ea) (commit date: 2026-06-08 12:58:59+00:00) - Imported: (`3.14.5+`) - [`51e83ca`](https://www.github.com/python/cpython/commit/51e83ca706d04878e0f6f0bf8030e0dd2f7585a6) (commit date: 2026-06-09 22:48:25+00:00) # Noteworthy file changes - Native files (2 added): ``` + Modules/_testcapi/weakref.c + Modules/_testlimitedcapi/weakref.c ``` - Test files (1 added) - Low-signal files (14 added, 3 removed) (NEWS.d, docs, .github) Complete list of added/removed files: https://www.internalfb.com/intern/everpaste/?color=0&handle=GMci3SqBZT1xMMcFAGiA-UwAcm1sbr0LAAAz Reviewed By: itamaro Differential Revision: D108133995 fbshipit-source-id: 2f69973b127d0430c08db8ece89952daa200cff0
1 parent ecefe34 commit ccebbb4

77 files changed

Lines changed: 1464 additions & 427 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/build.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,10 @@ jobs:
305305
# unsupported as it most resembles other 1.1.1-work-a-like ssl APIs
306306
# supported by important vendors such as AWS-LC.
307307
- { name: openssl, version: 1.1.1w }
308-
- { name: openssl, version: 3.0.20 }
309-
- { name: openssl, version: 3.3.7 }
310-
- { name: openssl, version: 3.4.5 }
311-
- { name: openssl, version: 3.5.6 }
312-
- { name: openssl, version: 3.6.2 }
308+
- { name: openssl, version: 3.0.21 }
309+
- { name: openssl, version: 3.4.6 }
310+
- { name: openssl, version: 3.5.7 }
311+
- { name: openssl, version: 3.6.3 }
313312
env:
314313
SSLLIB_VER: ${{ matrix.ssllib.version }}
315314
MULTISSL_DIR: ${{ github.workspace }}/multissl
@@ -423,7 +422,7 @@ jobs:
423422
needs: build-context
424423
if: needs.build-context.outputs.run-ubuntu == 'true'
425424
env:
426-
OPENSSL_VER: 3.5.6
425+
OPENSSL_VER: 3.5.7
427426
PYTHONSTRICTEXTENSIONBUILD: 1
428427
steps:
429428
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -531,7 +530,7 @@ jobs:
531530
matrix:
532531
os: [ubuntu-24.04]
533532
env:
534-
OPENSSL_VER: 3.5.6
533+
OPENSSL_VER: 3.5.7
535534
PYTHONSTRICTEXTENSIONBUILD: 1
536535
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
537536
steps:

.github/workflows/reusable-ubuntu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
runs-on: ${{ inputs.os }}
3131
timeout-minutes: 60
3232
env:
33-
OPENSSL_VER: 3.5.6
33+
OPENSSL_VER: 3.5.7
3434
PYTHONSTRICTEXTENSIONBUILD: 1
3535
TERM: linux
3636
steps:

Android/android.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def unpack_deps(host, prefix_dir, cache_dir):
216216
for name_ver in [
217217
"bzip2-1.0.8-3",
218218
"libffi-3.4.4-3",
219-
"openssl-3.5.6-0",
219+
"openssl-3.5.7-0",
220220
"sqlite-3.50.4-0",
221221
"xz-5.4.6-1",
222222
"zstd-1.5.7-2"

Apple/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def unpack_deps(
319319
for name_ver in [
320320
"BZip2-1.0.8-2",
321321
"libFFI-3.4.7-2",
322-
"OpenSSL-3.5.6-1",
322+
"OpenSSL-3.5.7-1",
323323
"XZ-5.6.4-2",
324324
"mpdecimal-4.0.0-2",
325325
"zstd-1.5.7-1",

Doc/library/argparse.rst

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,8 @@ is considered equivalent to the expression ``['-f', 'foo', '-f', 'bar']``.
442442

443443
.. note::
444444

445-
Empty lines are treated as empty strings (``''``), which are allowed as values but
446-
not as arguments. Empty lines that are read as arguments will result in an
447-
"unrecognized arguments" error.
445+
Each line is treated as a single argument, so an empty line is read as an
446+
empty string (``''``).
448447

449448
:class:`ArgumentParser` uses :term:`filesystem encoding and error handler`
450449
to read the file containing arguments.
@@ -1048,6 +1047,10 @@ is used when no command-line argument was present::
10481047
>>> parser.parse_args([])
10491048
Namespace(foo=42)
10501049

1050+
Because ``nargs='*'`` gathers any supplied values into a list, an absent
1051+
positional argument yields an empty list (``[]``). Only a non-``None``
1052+
*default* overrides this (so ``default=None`` still gives ``[]``).
1053+
10511054
For required_ arguments, the ``default`` value is ignored. For example, this
10521055
applies to positional arguments with nargs_ values other than ``?`` or ``*``,
10531056
or optional arguments marked as ``required=True``.
@@ -1360,6 +1363,10 @@ behavior::
13601363
>>> parser.parse_args('--foo XXX'.split())
13611364
Namespace(bar='XXX')
13621365

1366+
Multiple arguments may share the same ``dest``. By default, the value from the
1367+
last such argument given on the command line wins. Use ``action='append'`` to
1368+
collect values from all of them into a list instead. For conflicting *option
1369+
strings* rather than ``dest`` names, see conflict_handler_.
13631370

13641371
.. _deprecated:
13651372

@@ -1755,6 +1762,11 @@ Subcommands
17551762
present, and when the ``b`` command is specified, only the ``foo`` and
17561763
``baz`` attributes are present.
17571764

1765+
If a subparser defines an argument with the same ``dest`` as the parent
1766+
parser, the two share a single namespace attribute, so the parent's value
1767+
won't be retained. Users should give them distinct ``dest`` values to
1768+
keep both.
1769+
17581770
Similarly, when a help message is requested from a subparser, only the help
17591771
for that particular parser will be printed. The help message will not
17601772
include parent parser or sibling parser messages. (A help message for each
@@ -2199,6 +2211,9 @@ Customizing file parsing
21992211
def convert_arg_line_to_args(self, arg_line):
22002212
return arg_line.split()
22012213

2214+
Note that with this override an argument can no longer contain spaces, since
2215+
each space-separated word becomes a separate argument.
2216+
22022217

22032218
Exiting methods
22042219
^^^^^^^^^^^^^^^

Doc/library/collections.abc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin:
459459
The :class:`Set` mixin provides a :meth:`!_hash` method to compute a hash value
460460
for the set; however, :meth:`~object.__hash__` is not defined because not all sets
461461
are :term:`hashable` or immutable. To add set hashability using mixins,
462-
inherit from both :meth:`Set` and :meth:`Hashable`, then define
462+
inherit from both :class:`Set` and :class:`Hashable`, then define
463463
``__hash__ = Set._hash``.
464464

465465
.. seealso::

Doc/library/pyexpat.rst

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,71 @@ XMLParser Objects
238238
.. versionadded:: 3.13
239239

240240

241-
:class:`!xmlparser` objects have the following methods to mitigate some
242-
common XML vulnerabilities.
241+
:class:`!xmlparser` objects have the following methods to tune protections
242+
against some common XML vulnerabilities.
243+
244+
.. method:: xmlparser.SetBillionLaughsAttackProtectionActivationThreshold(threshold, /)
245+
246+
Sets the number of output bytes needed to activate protection against
247+
`billion laughs`_ attacks.
248+
249+
The number of output bytes includes amplification from entity expansion
250+
and reading DTD files.
251+
252+
Parser objects usually have a protection activation threshold of 8 MiB,
253+
but the actual default value depends on the underlying Expat library.
254+
255+
An :exc:`ExpatError` is raised if this method is called on a
256+
|xml-non-root-parser| parser.
257+
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
258+
should not be used as they may have no special meaning.
259+
260+
.. note::
261+
262+
Activation thresholds below 4 MiB are known to break support for DITA 1.3
263+
payload and are hence not recommended.
264+
265+
.. versionadded:: next
266+
267+
.. method:: xmlparser.SetBillionLaughsAttackProtectionMaximumAmplification(max_factor, /)
268+
269+
Sets the maximum tolerated amplification factor for protection against
270+
`billion laughs`_ attacks.
271+
272+
The amplification factor is calculated as ``(direct + indirect) / direct``
273+
while parsing, where ``direct`` is the number of bytes read from
274+
the primary document in parsing and ``indirect`` is the number of
275+
bytes added by expanding entities and reading of external DTD files.
276+
277+
The *max_factor* value must be a non-NaN :class:`float` value greater than
278+
or equal to 1.0. Peak amplifications of factor 15,000 for the entire payload
279+
and of factor 30,000 in the middle of parsing have been observed with small
280+
benign files in practice. In particular, the activation threshold should be
281+
carefully chosen to avoid false positives.
282+
283+
Parser objects usually have a maximum amplification factor of 100,
284+
but the actual default value depends on the underlying Expat library.
285+
286+
An :exc:`ExpatError` is raised if this method is called on a
287+
|xml-non-root-parser| parser or if *max_factor* is outside the valid range.
288+
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
289+
should not be used as they may have no special meaning.
290+
291+
.. note::
292+
293+
The maximum amplification factor is only considered if the threshold
294+
that can be adjusted by :meth:`.SetBillionLaughsAttackProtectionActivationThreshold`
295+
is exceeded.
296+
297+
.. versionadded:: next
243298

244299
.. method:: xmlparser.SetAllocTrackerActivationThreshold(threshold, /)
245300

246301
Sets the number of allocated bytes of dynamic memory needed to activate
247302
protection against disproportionate use of RAM.
248303

249-
By default, parser objects have an allocation activation threshold of 64 MiB,
250-
or equivalently 67,108,864 bytes.
304+
Parser objects usually have an allocation activation threshold of 64 MiB,
305+
but the actual default value depends on the underlying Expat library.
251306

252307
An :exc:`ExpatError` is raised if this method is called on a
253308
|xml-non-root-parser| parser.
@@ -271,7 +326,8 @@ common XML vulnerabilities.
271326
near the start of parsing even with benign files in practice. In particular,
272327
the activation threshold should be carefully chosen to avoid false positives.
273328

274-
By default, parser objects have a maximum amplification factor of 100.0.
329+
Parser objects usually have a maximum amplification factor of 100,
330+
but the actual default value depends on the underlying Expat library.
275331

276332
An :exc:`ExpatError` is raised if this method is called on a
277333
|xml-non-root-parser| parser or if *max_factor* is outside the valid range.
@@ -1019,4 +1075,6 @@ The ``errors`` module has the following attributes:
10191075
not. See https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl
10201076
and https://www.iana.org/assignments/character-sets/character-sets.xhtml.
10211077
1078+
1079+
.. _billion laughs: https://en.wikipedia.org/wiki/Billion_laughs_attack
10221080
.. |xml-non-root-parser| replace:: :ref:`non-root <xmlparser-non-root>`

Doc/library/shutil.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,14 @@ Directory and files operations
388388
If *dst* already exists but is not a directory, it may be overwritten
389389
depending on :func:`os.rename` semantics.
390390

391-
If the destination is on the current filesystem, then :func:`os.rename` is
392-
used. Otherwise, *src* is copied to the destination using *copy_function*
393-
and then removed. In case of symlinks, a new symlink pointing to the target
394-
of *src* will be created as the destination and *src* will be removed.
391+
:func:`os.rename` is preferably used internally when *src* and the destination are on
392+
the same filesystem. In case :func:`os.rename` fails due to :exc:`OSError`
393+
(e.g. the user has write permission to the destination file but not to its parent
394+
directory), this method falls back to using *copy_function*, in which case
395+
*src* is copied to the destination using *copy_function* and then removed.
396+
397+
In case of symlinks, a new symlink pointing to the target of *src* will be
398+
created in or as the destination, and *src* will be removed.
395399

396400
If *copy_function* is given, it must be a callable that takes two arguments,
397401
*src* and the destination, and will be used to copy *src* to the destination

Include/internal/pycore_pyhash.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ _Py_HashPointerRaw(const void *ptr)
2727
* pppppppp ssssssss ........ fnv -- two Py_hash_t
2828
* k0k0k0k0 k1k1k1k1 ........ siphash -- two uint64_t
2929
* ........ ........ ssssssss djbx33a -- 16 bytes padding + one Py_hash_t
30-
* ........ ........ eeeeeeee pyexpat XML hash salt
30+
* eeeeeeee eeeeeeee eeeeeeee pyexpat XML hash salt
3131
*
3232
* memory layout on 32 bit systems
3333
* cccccccc cccccccc cccccccc uc
3434
* ppppssss ........ ........ fnv -- two Py_hash_t
3535
* k0k0k0k0 k1k1k1k1 ........ siphash -- two uint64_t (*)
3636
* ........ ........ ssss.... djbx33a -- 16 bytes padding + one Py_hash_t
37-
* ........ ........ eeee.... pyexpat XML hash salt
37+
* eeeeeeee eeeeeeee eeee.... pyexpat XML hash salt
3838
*
3939
* (*) The siphash member may not be available on 32 bit platforms without
4040
* an unsigned int64 data type.
@@ -58,7 +58,9 @@ typedef union {
5858
Py_hash_t suffix;
5959
} djbx33a;
6060
struct {
61-
unsigned char padding[16];
61+
/* 16 bytes for XML_SetHashSalt16Bytes */
62+
uint8_t hashsalt16[16];
63+
/* 4/8 bytes for legacy XML_SetHashSalt */
6264
Py_hash_t hashsalt;
6365
} expat;
6466
} _Py_HashSecret_t;

Include/pyexpat.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ struct PyExpat_CAPI
5757
XML_Parser parser, unsigned long long activationThresholdBytes);
5858
XML_Bool (*SetAllocTrackerMaximumAmplification)(
5959
XML_Parser parser, float maxAmplificationFactor);
60+
/* might be NULL for expat < 2.4.0 */
61+
XML_Bool (*SetBillionLaughsAttackProtectionActivationThreshold)(
62+
XML_Parser parser, unsigned long long activationThresholdBytes);
63+
XML_Bool (*SetBillionLaughsAttackProtectionMaximumAmplification)(
64+
XML_Parser parser, float maxAmplificationFactor);
65+
/* might be NULL for expat < 2.8.0 */
66+
XML_Bool (*SetHashSalt16Bytes)(
67+
XML_Parser parser, const uint8_t entropy[16]);
6068
/* always add new stuff to the end! */
6169
};
6270

0 commit comments

Comments
 (0)