14729 Commits
Author SHA1 Message Date
cb3a838553 [3.13] gh-158876: Update bundled Expat to 2.9.0 (GH-158881) (#160257)
(cherry picked from commit 0071fb5111)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: T. Wouters <thomas@python.org>
2026-10-25 06:49:20 -07:00
Gregory P. SmithandChristian Heimes 98f0e4ed34 [3.13] gh-160040: Distrust compromised eMudhra intermediate CA keys (CVE-2026-115557) (GH-160042) (#160570)
The ssl module now rejects TLS certificate chains that contain any of a set of
compromised eMudhra intermediate CA keys.  This is an extraordinary measure and
a last line of defense: removing trust is primarily the job of the platform root
store, and the built-in denylist only blocks connections while that update has
not yet reached the OS, a container image, or a bundled trust store in various
Python packages.  Entries are added to the denylist only under a very high
threshold.

The denylist matches on the public key (the SHA-256 digest of the RFC-5280
SubjectPublicKeyInfo), so it also covers the cross-signed certificates that
reuse one of the distrusted keys.

(cherry picked from commit 7dd8b4736a)

Co-authored-by: Christian Heimes <christian@python.org>
2026-10-24 12:28:52 -07:00
Seth LarsonandGregory P. Smith d8717ed017 [3.13] gh-156293: Use-after-free for server-side SSLContext with sni_… (#158507)
Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
2026-09-30 18:35:27 +03:00
Bénédikt Tran 33a65116df [3.13] gh-155835: fix digest_size and block_size data races on SHA-3 objects (GH-155838) (#157041)
* [3.13] gh-155835: fix `digest_size` and `block_size` data races on SHA-3 objects (GH-155838)
(cherry picked from commit 90ac5398e4)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-09-29 21:57:07 +00:00
Timofei Ivankov fc9b015d94 [3.13] gh-157301: Fix asyncio event loop hanging on a failed eager task start (#157845)
gh-157301: Fix asyncio event loop hanging on a failed eager task start
2026-09-29 23:37:50 +02:00
69368ebc33 [3.13] gh-158102: Add tests for the slice C API (GH-158120) (GH-158293)
Test PySlice_Check(), PySlice_New(), PySlice_GetIndices(), PySlice_Unpack(),
PySlice_AdjustIndices() and PySlice_GetIndicesEx() -- both the macro and the
deprecated function.

Document the length and step precondition of PySlice_AdjustIndices()
(cherry picked from commit 8c056c33aa)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-09-29 15:38:46 +03:00
Zachary Ware 08e590e404 [3.13] gh-158010: Update OpenSSL in binaries and CI from 3.0 to 3.5 (#158015)
Includes addition of `Modules/_ssl_data*.h` definitions backported from 3.14's `Modules/_ssl_data_35.h`.
(adapted from commit cf526738ca)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-09-28 01:14:19 +02:00
Peter BiermaandLazizbek Ergashev ca0cdf42cf [3.13] gh-156933: Widen narrow integer results in ctypes callbacks (GH-157045) (GH-158297)
_CallPythonObject() only wrote restype->size bytes into the closure's result buffer, leaving the unused high-order bits of the ffi_arg-sized register untouched. libffi's ffi_prep_closure_loc() documents that integral types narrower than a machine register must be widened to fill it, sign-extending signed types. On architectures that always read the full register for narrow return values (s390x), this leaves garbage in the high bits, which broke libclang callbacks used by cindex.py.

(cherry picked from commit b6f9a50e65)

Co-authored-by: Lazizbek Ergashev <lazerg2@gmail.com>
2026-09-27 19:04:34 +00:00
ba208275e2 [3.13] gh-158169: Clear zlib.Decompress.unconsumed_tail at end of stream (GH-158177) (GH-158229) (#158243)
[3.14] gh-158169: Clear `zlib.Decompress.unconsumed_tail` at end of stream (GH-158177) (GH-158229)

(cherry picked from commit 8122ff4818)

Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: GruffElixir <samarthat9@gmail.com>
2026-09-26 16:42:29 +00:00
Miss Islington (bot)andStan Ulbrych af1be50e4c [3.13] gh-157325: Fix an OOB read in the hz incremental decoder on a trailing ~ (gh-157333) (#158161)
(cherry picked from commit c04387348e)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-09-25 15:58:15 +01:00
Pablo Galindo SalgadoandLazizbek Ergashev 46d85fb1a3 [3.13] gh-157639: Fix use-after-free when an external timer re-enters the profiler (GH-157648) (#158118)
(cherry picked from commit a6fa91cab2)

Co-authored-by: Lazizbek Ergashev <lazerg2@gmail.com>
2026-09-24 16:29:08 +00:00
Miss Islington (bot)andStan Ulbrych 6ff52cd6fd [3.13] Add PyExc_OverflowError to the list of possible exceptions in fuzz_ast_literal_eval fuzzer (GH-145429) (#158083)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2026-09-24 16:57:15 +03:00
bb8572f90a [3.13] gh-155526: Don't check errno in abs(complex) (GH-155527) (#157341) (#157558)
[3.15] gh-155526: Don't check errno in abs(complex) (GH-155527) (#157341)



(cherry picked from commit 340cfbaf67)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: hpkfft.com <paul@hpkfft.com>
2026-09-24 00:09:46 +02:00
Victor StinnerandJoseph Kerry edabbff90b [3.13] gh-157335: Fix out-of-bounds write in mmap.mmap.__setitem__ (#157438) (#158028)
gh-157335: Fix out-of-bounds write in mmap.mmap.__setitem__ (#157438)

Fix out-of-bounds write in mmap.mmap.__setitem__() that could occur
when converting the index or the assigned value (via __index__()
for a single item, or via the buffer protocol for a slice) resized or closed
the mmap object during the assignment.


(cherry picked from commit 09bf4c5258)

Co-authored-by: Joseph Kerry <joerkerry@gmail.com>
2026-09-23 21:14:26 +00:00
Miss Islington (bot)andStan Ulbrych 388a06c263 [3.13] gh-157953: Update bundled Expat to 2.8.5 (GH-157957) (#157997)
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-09-23 14:10:37 +00:00
Serhiy Storchaka 159a3604b9 [3.13] gh-157672: Keep Python's signal handlers when Tk is initialized on macOS (GH-157673) (GH-157989)
Tk on macOS replaces the SIGINT, SIGHUP and SIGTERM handlers with its
own, which exits the process, so Ctrl-C terminated a tkinter program
instead of raising KeyboardInterrupt.  Save the handlers installed by
Python before Tk_Init() and restore them after it.

This affects Tk 8.6.11 to 8.6.18 and 9.0 to 9.0.4.  Tk itself is fixed
in 8.6.19 and 9.0.5.

(cherry picked from commit 4532b36db5)

On 3.13 there was no Tkinter_TkInit(), and tkappinit.c, which is used
when Python is built with WITH_APPINIT (as on macOS), called Tk_Init()
directly, bypassing the fix.
2026-09-23 11:40:46 +00:00
Serhiy StorchakaandVyron Vasileiadis f63df3746c [3.13] gh-156946: Unlink a curses panel before dropping its user pointer (GH-156947) (GH-157542)
A __del__ of the user pointer could get the panel being deallocated
from top_panel() and crash the interpreter.
(cherry picked from commit df02e264c8)

Co-authored-by: Vyron Vasileiadis <hi@fedonman.com>
2026-09-15 08:25:53 +00:00
c28b121a4f [3.13] gh-155292: Don't consider Unicode codepoint attributes outside RFC 3454 (GH-155293) (GH-156020) (GH-156922)
Due to a bug, some Unicode codepoint attributes were considered
for characters not yet defined in Unicode 3.2.0 or attributes
which changed in later Unicode versions. RFC 3454 (StringPrep)
requires using Unicode 3.2.0 strictly.

(cherry picked from commit 7e109d084d)
The cherry-pick needed reworking as GH-144815 wasn't backported to 3.14
and below, so unassigned characters don't have bidi values.
(cherry picked from commit 1e54caa096)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Seth Larson <seth@python.org>
Co-authored-by: Stan Ulbrych <89152624+stanfromireland@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>

---------

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Seth Larson <seth@python.org>
Co-authored-by: Stan Ulbrych <89152624+stanfromireland@users.noreply.github.com>
2026-09-09 16:28:35 +02:00
Miss Islington (bot)andGregory P. Smith 91245cb6d9 [3.13] gh-157142: Fix linking _freeze_module with built-in test modules (GH-157143) (#157150)
gh-157142: Fix linking _freeze_module with built-in test modules (GH-157143)

Programs/_freeze_module is linked with Modules/getpath_noop.o rather than
Modules/getpath.o, and getpath_noop.c only defined _PyConfig_InitPathConfig().
With MODULE_BUILDTYPE=static (the default on wasm), _testinternalcapi.o is
part of LIBRARY_OBJS_OMIT_FROZEN and its get_getpath_codeobject() left
_Py_Get_Getpath_CodeObject() as an undefined reference. Define a stub for it.
(cherry picked from commit c8da735f4f)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
2026-09-08 01:53:26 +00:00
Miss Islington (bot)andVictor Stinner 1c5df82471 [3.13] gh-156939: Fix struct.pack('0p', bytes) (GH-157071) (#157131)
gh-156939: Fix struct.pack('0p', bytes) (GH-157071)

If the Pascal string is empty (size=0), do not write the size prefix.
Previously, a NUL byte was written outsize the buffer (buffer
overflow). In practice, the write remains into allocated memory
and is silently ignored: no memory is corrupted.
(cherry picked from commit 23525c90f5)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-09-07 19:57:45 +00:00
Nathan Goldbaum 88f6017a00 [3.13] gh-157048: check for buffer errors before mutating in BytesIO.__init__ (GH-157049) (#157070) 2026-09-07 10:04:22 -06:00
Serhiy Storchaka 3c36e4a8fe [3.13] gh-156821: Fix inaccuracies in the xml.parsers.expat documentation (GH-156822) (GH-156854)
Corrected, in the documentation and in the docstrings:

* GetInputContext() returns bytes, and its result extends to the end of the
  buffered input;
* Parse() accepts a bytes-like object as well as a string, and ignores the
  encoding declaration for a string;
* ParseFile() only supports binary files;
* XML_ERROR_XML_DECL was described as XML_ERROR_NO_ELEMENTS;
* UnparsedEntityDeclHandler is not restricted to Expat 1.2;
* GetSpecifiedAttributeCount() needs ordered_attributes.

Documented the intern parameter and attribute, namespace_prefixes,
SkippedEntityHandler, XML_CTYPE_MIXED and XML_CTYPE_NAME, and EXPAT_VERSION,
version_info and features.

Removed obsolete notes about Expat 1.2 and 1.95.0, and :noindex: from the
content model constants, which are not documented elsewhere; completed the
list of attribute types in AttlistDeclHandler.
(cherry picked from commit d16a691111)
2026-09-03 00:08:49 +03:00
Serhiy Storchaka 0622638cc9 [3.13] gh-83895: Accept input larger than 2 GiB in the C implementation of ElementTree (GH-156746) (GH-156773)
XMLParser.feed() and ElementTree.parse() raised OverflowError, because Expat
takes the length as an int.  The data is now fed to Expat in chunks of 1 MiB,
as xml.parsers.expat does since bpo-17089, so the pure Python implementation
already accepted such input.
(cherry picked from commit 9259e8ba4d)
2026-09-01 15:54:25 +00:00
Serhiy Storchaka 16f4deefab [3.13] gh-99064: Ignore the encoding declaration when parsing decoded text (GH-156734) (GH-156752)
ElementTree.parse() with a text file mis-decoded the text in the C
implementation: _parse_whole() encoded it as UTF-8, but left expat to honor
the encoding declared in the document.  It now overrides the encoding, as
XMLParser.feed() already does for str data.
(cherry picked from commit c83013c92d)
2026-09-01 07:53:03 +00:00
Miss Islington (bot)andStan Ulbrych a371ba8c77 [3.13] gh-156723: Update bundled libexpat to version 2.8.4 (GH-156724) (#156733)
(cherry picked from commit 287b7cffb7)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-08-31 18:44:43 +00:00
f89654e3dc [3.13] gh-72353: Continue reading from the console after ignored Ctrl+C (GH-155434) (GH-156591)
If the console cancels a read because of Ctrl+C, but the SIGINT handler
does not raise an exception, restart the read instead of ending it as if
at end of file.
(cherry picked from commit c922aa0ddd)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Valeriya Sinevich <valeriya.sinevich@phystech.edu>
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2026-08-30 18:31:59 +00:00
Miss Islington (bot)andStan Ulbrych b708802e5b [3.13] Fix a dangling pointer and reference leak in local_timezone_from_timestamp (GH-156598) (#156645)
(cherry picked from commit fcf0a98700)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-08-30 11:06:30 +00:00
Serhiy Storchaka dfa5f4c805 [3.13] gh-84419: Fix the execute permissions in os.stat() on Windows (GH-155392) (GH-156631)
Windows strips trailing dots and spaces from the last component of the path,
so os.stat('spam.bat ') opened the same file as os.stat('spam.bat'), but did
not set the execute permissions in st_mode, because the extension did not
match.  They are now ignored, unless the \\?\ prefix disables the path
normalization.

(cherry picked from commit b7daede668)
2026-08-30 08:12:53 +00:00
Miss Islington (bot)andVyron Vasileiadis 44a46281a5 [3.13] gh-153772: Make abc isinstance() tolerate instances without __class__ (GH-154149) (#156543)
gh-153772: Make abc isinstance() tolerate instances without __class__ (GH-154149)

The built-in isinstance() reads an instance's __class__ with a lookup that
suppresses AttributeError and falls back to the object's type, so
isinstance(obj, int) returns False for an object whose __class__ access
raises. ABCMeta.__instancecheck__ read __class__ directly instead, so
isinstance(obj, Mapping) leaked that AttributeError.

Fall back to type(instance) when __class__ is unavailable, in both the C
and the pure-Python implementations, so the abstract base classes behave
like the built-in isinstance(). Such objects are unusual, but they do turn
up in the wild (for example some Qt widgets).
(cherry picked from commit 3e245faf34)

Co-authored-by: Vyron Vasileiadis <hi@fedonman.com>
2026-08-29 03:33:29 +00:00
Stan UlbrychandOmar Sandoval c6d191dc2a [3.13] Fix various issues in the 'Timer File Descriptors' documentation (GH-156027) (#156480)
(cherry picked from commit 13ab4c2861)

Co-authored-by: Omar Sandoval <osandov@osandov.com>
2026-08-27 16:32:50 +00:00
7e7e88f674 [3.13] gh-156444: Fix a negated character set with IGNORECASE and LOCALE (GH-156445) (GH-156458)
charset_loc_ignore() tested the whole set once per locale case and took
the disjunction, which complements a set before closing it under case
instead of after: [bc] matched b'B', but so did [^bc].  Match both cases
of the character against every set member instead.
(cherry picked from commit 6671d27327)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 11:40:52 +00:00
Serhiy Storchaka 7d7fa9d73b [3.13] gh-154855: Ask non-ncurses curses for one more character (GH-154870) (GH-156285)
Passing n to the library is ncurses' reading of n: it stores n characters
and adds a terminator.  NetBSD curses counts the terminator in n.

Ask a library that is neither ncurses nor PDCurses for n + 1, and read
again if it stored more than asked; truncating could split a multibyte
character.  This is not possible for input, so getstr() is left as it is.

instr() now takes the length from the value returned by winnstr(), as
X/Open specifies, instead of searching for a terminator which it does not.

(cherry picked from commit 43a1869f7e)
2026-08-23 13:07:20 +00:00
Serhiy Storchaka 2eb7ed5541 [3.13] gh-156234: Fix and rewrite the curses documentation on reading (GH-156235) (GH-156281)
Fix wrong types: instr() and getstr() return a bytes object, not a str, and
their n limits the number of bytes; getkey() returns a str; unctrl() returns
a bytes object.  Make clear whether an integer standing for a character is an
encoded byte or a character code.

Rewrite the documentation of getch(), get_wch(), getkey(), getstr() and
instr(), following X/Open Curses.

The docstrings of getstr() and instr() said that n defaults to 2047, while
the limit on this branch is 1023.

(cherry picked from commit be87bfa8a1)
2026-08-23 12:18:21 +00:00
Miss Islington (bot)andStan Ulbrych 2786b696bf [3.13] gh-156173: Fix zlib.Decompress.flush() silently returning corrupted output instead of raising zlib.error (GH-156176) (#156272)
(cherry picked from commit 54426877bd)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-08-23 10:47:29 +01:00
Serhiy Storchakaandtonghuaroot 081e0beae2 [3.13] gh-153539: Fix use-after-free in TextIOWrapper.tell() with a reentrant decoder (GH-153540) (GH-156195)
TextIOWrapper.tell() used a borrowed next_input from the snapshot across the
decoder's getstate/decode/setstate calls, so a decoder that reenters seek()
from getstate could free it and leave tell() reading freed memory. Own the
reference across those calls, matching the sibling textiowrapper_read_chunk.

(cherry picked from commit fa0ec86ab6)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
2026-08-21 15:51:44 +00:00
Serhiy Storchaka 3d937eb1f9 [3.13] gh-156166: Fix setting and deleting SSLContext._msg_callback (GH-156167) (GH-156175)
The setter released the old callback before validating the new value,
so a failed assignment or a deletion removed it.

(cherry picked from commit 67f4d53425)
2026-08-21 16:48:12 +03:00
stevensandStan Ulbrych 45169108b7 [3.13] gh-155952: Fix <unrepresentable> Argument Clinic defaults in several signatures (#156170)
(cherry picked from commit 5a7fd42138)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-08-21 13:25:13 +01:00
Serhiy StorchakaandSteve Stagg 4f3afba4fe [3.13] gh-152817: Prevent deletion of sqlite3 cursor.row_factory attr (GH-152818) (GH-156162)
(cherry picked from commit 8e96dd6f25)

Co-authored-by: Steve Stagg <stestagg@gmail.com>
2026-08-21 08:50:42 +00:00
Serhiy Storchaka 6b3d4eae81 [3.13] gh-156099: Fix a crash when deleting SSLContext.keylog_filename (GH-156103) (GH-156150)
The setter did not check the value for NULL and passed it to Py_fopen().

(cherry picked from commit 5ebd4860d3)
2026-08-21 08:41:10 +00:00
Serhiy Storchaka fbf7a0680f [3.13] gh-156100: Fix crashes in the sqlite3 Connection.autocommit setter (GH-156104) (GH-156155)
Deleting the attribute crashed, and setting it to an integer which does not
fit in C long reported success with OverflowError set.

(cherry picked from commit daebcac92d)
2026-08-21 07:32:56 +00:00
Miss Islington (bot)andStan Ulbrych 200b98b9fb [3.13] gh-156067: Fix two error handling issues in _zoneinfo.load_data() (GH-156068) (#156090)
(cherry picked from commit 21a6a8a892)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-08-20 09:37:56 +00:00
Serhiy Storchaka acdecb345d [3.13] gh-113318: Fix @getter and @setter in Argument Clinic (GH-155778) (GH-156012)
(cherry picked from commit 915970ce9d)
2026-08-18 13:09:10 +00:00
Miss Islington (bot)andtonghuaroot f0e236e50e [3.13] gh-153603: Fix out-of-bounds read in the ISO-2022 decoder for an unknown charset (GH-153604) (GH-155961)
The designation-table scan compiled its terminator only under Py_DEBUG, so a
release build walked off the table for an unknown charset set via setstate().
Make the terminator unconditional and report the byte as undecodable.
(cherry picked from commit f40043e095)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
2026-08-17 13:27:28 +00:00
Serhiy StorchakaandStan Ulbrych e4046ce6f2 [3.13] gh-155787: Harmonize parameter names in the time module documentation and docstrings (GH-155790) (GH-155807)
(cherry picked from commit bc6749cc3b)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-08-15 08:52:22 +03:00
Miss Islington (bot)andStan Ulbrych 35c8011e74 [3.13] gh-155558: Update bundled Expat to 2.8.3 (GH-155560) (#155614)
(cherry picked from commit 3d6a50598b)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-08-12 11:38:37 +00:00
Jakub Kulík 9622dec7c8 [3.13] gh-155336: Preserve resolver errors from gethostby*_r() (GH-155337) (GH-155473)
(cherry picked from commit 5181a6eca5)
2026-08-11 08:43:39 +00:00
Serhiy StorchakaandClaude Opus 5 80c6519790 [3.13] gh-64502: Fix Argument Clinic support of optional groups with defaults (GH-155191) (GH-155217)
Parameters with a default value which are not in any group were always
required in the generated argument parsing code, although they were
rendered as optional in the signature.  They can now be omitted, and
ambiguous combinations of optional groups and parameters with a default
value are rejected.
(cherry picked from commit caac927830)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 14:39:17 +03:00
Serhiy StorchakaandClaude Opus 5 965c21d9f7 [3.13] gh-155218: Generate the option group flags in a stable order (GH-155219) (GH-155225)
They were emitted in the iteration order of a set of group identifiers.
The identifiers of the groups before the required parameters are small
negative integers, -1 and -2 have the same hash, so their order depended
on the size of Py_hash_t, and the code generated on a 32-bit platform
differed from the checked in one.

They are now emitted in the order of the parameters.
(cherry picked from commit 7aec160315)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 09:27:21 +00:00
Miss Islington (bot)andEdward Xu 75344c0683 [3.13] gh-154937: Fix _thread._shutdown() racing with _thread.start_joinable_thread on ThreadHandle.ident (GH-155085) (#155125)
* gh-154937: Fix `_thread._shutdown()` racing with `_thread.start_joinable_thread` on `ThreadHandle.ident` (GH-155085)
(cherry picked from commit a4095ee272)

Co-authored-by: Edward Xu <xuxiangad@gmail.com>
2026-08-04 09:27:41 +00:00
Miss Islington (bot)andBhuvansh 22aea1c477 [3.13] gh-154871: Fix asyncio.Task.get_context() crash on uninitialized tasks (GH-154898) (#155021)
gh-154871: Fix `asyncio.Task.get_context()` crash on uninitialized tasks (GH-154898)
(cherry picked from commit afd10f0e28)

Co-authored-by: Bhuvansh <bhuvanshkataria@gmail.com>
2026-08-04 11:00:46 +02:00