Commit graph

55896 commits

Author SHA1 Message Date
Miss Islington (bot)
2459faaaa9
[3.14] gh-148663: Document that calendar.IllegalMonthError inherits from both ValueError and IndexError (GH-148664) (#148917)
(cherry picked from commit 435be06dd2)

Co-authored-by: Eoin Shaughnessy <45000144+EoinTrial@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-27 21:00:46 +01:00
Miss Islington (bot)
b01e594fbe
[3.14] gh-146581: Fix vulnerability in shutil.unpack_archive() for ZIP files on Windows (GH-146591) (GH-149064)
Use ZipFile.extractall() to sanitize file names and extract files.

Files with invalid names (e.g. absolute paths) are now skipped.

Files containing ".." in the name are no longer skipped.
(cherry picked from commit fc829e8875)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-04-27 22:55:02 +03:00
Thomas Kowalski
0cd8123535
[3.14] Un-skip previously-broken test_get_type_hints_modules_forward_ref (#149053) 2026-04-27 09:54:56 -07:00
Sergey Miryanov
9a7e205e46
[3.14] GH-148726: Forward-port generational GC (#148720)
Co-authored-by: Neil Schemenauer <nas@arctrix.com>
Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Zanie Blue <contact@zanie.dev>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
2026-04-26 21:12:52 +03:00
Miss Islington (bot)
5770df43dc
[3.14] gh-141473: Speed up subprocess test_communicate_timeout_large_input long tail (GH-149003) (#149004)
gh-141473: Speed up subprocess test_communicate_timeout_large_input long tail (GH-149003)

gh-141473: Speed up test_communicate_timeout_large_input

Replace the slow reader's 30s sleep with a parent-driven wake over a
loopback socket so post-timeout communicate() doesn't block waiting
for the child to wake on its own. Worst-case runtime: ~30s -> <1s.
(cherry picked from commit e1384cfd25)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
2026-04-26 04:29:47 +00:00
Miss Islington (bot)
15e2b64cd8
[3.14] gh-148947: dataclasses: fix error on empty __class__ cell (GH-148948) (#148995)
gh-148947: dataclasses: fix error on empty __class__ cell  (GH-148948)

Also add a test demonstrating the need for the existing "is oldcls" check.
(cherry picked from commit 6d7bbee1d5)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2026-04-25 15:57:33 +00:00
Miss Islington (bot)
8acb98a1c2
[3.14] gh-148973: fix segfault on mismatch between consts size and oparg in compiler (GH-148974) (#148980)
gh-148973: fix segfault on mismatch between consts size and oparg in compiler (GH-148974)
(cherry picked from commit c650b51c32)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-04-25 13:53:42 +01:00
Miss Islington (bot)
89f44ac422
[3.14] gh-148735: Fix a UAF in Element.findtext() (GH-148738) (#148916)
(cherry picked from commit 0469e6d38d)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-24 21:38:15 +01:00
Sam Gross
26c6e3d7e3
[3.14] gh-113956: Make intern_common thread-safe in free-threaded build (gh-148886) (#148927)
Avoid racing with the owning thread's refcount operations when
immortalizing an interned string: if we don't own it and its refcount
isn't merged, intern a copy we own instead. Use atomic stores in
_Py_SetImmortalUntracked so concurrent atomic reads are race-free.

(cherry picked from commit 4629c2215a)
2026-04-23 19:12:19 +00:00
Miss Islington (bot)
31ba91a35e
[3.14] gh-132631: Fix "I/O operation on closed file" when parsing JSON Lines file (GH-132632) (#148921)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
2026-04-23 19:32:29 +03:00
Miss Islington (bot)
5e758ff525
[3.14] gh-148464: Add missing `__ctype_le/be__` attributes for complex types in the ctype module (GH-148485) (GH-148677)
(cherry picked from commit 769cc8338f)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-04-23 15:57:55 +02:00
Miss Islington (bot)
b6a7212edb
[3.14] gh-148680: Replace internal names with type_reprs of objects in string representations of ForwardRef (GH-148682) (#148913)
(cherry picked from commit 158dbbb97f)

Co-authored-by: David Ellis <ducksual@gmail.com>
Co-authored-by: Shamil <ashm.tech@proton.me>
2026-04-23 13:47:52 +00:00
Miss Islington (bot)
f795e04204
[3.14] gh-90309: Base64-encode cookie values embedded in JS (GH-148889)
(cherry picked from commit 76b3923d68)

Co-authored-by: Seth Larson <seth@python.org>
2026-04-23 15:05:09 +02:00
Miss Islington (bot)
27cd23470a
[3.14] gh-146553: Fix infinite loop in typing.get_type_hints() on circular __wrapped__ (GH-148595) (#148895)
(cherry picked from commit be833e658a)

Co-authored-by: Shamil <ashm.tech@proton.me>
2026-04-23 02:57:38 +00:00
Stan Ulbrych
5f1b710a28
[3.14] gh-148801: Fix unbound C recursion in Element.__deepcopy__() (GH-148802) (#148842)
(cherry picked from commit 33e82be174)
2026-04-22 22:19:25 +01:00
Miss Islington (bot)
27522b7d6e
[3.14] gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (GH-148809) (#148837)
gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (GH-148809)
(cherry picked from commit 1274766d3c)

Co-authored-by: Seth Larson <seth@python.org>
2026-04-21 21:56:19 +05:30
Miss Islington (bot)
b1cf901633
[3.14] gh-146211: Reject CR/LF in HTTP tunnel request headers (GH-146212) (#148342)
gh-146211: Reject CR/LF in HTTP tunnel request headers (GH-146212)
(cherry picked from commit 05ed7ce7ae)

Co-authored-by: Seth Larson <seth@python.org>
Co-authored-by: Illia Volochii <illia.volochii@gmail.com>
2026-04-21 10:49:37 +03:00
Miss Islington (bot)
a37b105eec
[3.14] gh-148653: Fix reference leaks in test_marshal introduced in gh-148698 (GH-148725) (GH-148727)
(cherry picked from commit 7ce737ea11)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-04-18 12:35:51 +00:00
Serhiy Storchaka
d496c637a3
[3.14] gh-148653: Fix some marshal errors related to recursive immutable objects (GH-148698) (GH-148711)
Forbid marshalling recursive code and slice objects which
cannot be correctly unmarshalled.
Add multiple tests for recursive data structures.
(cherry picked from commit 2e37d83641)
2026-04-18 08:57:55 +00:00
Jelle Zijlstra
1c9de6bbaa
[3.14] gh-137814: Fix __qualname__ of __annotate__ functions in the interpreter (#148221)
gh-137814: [3.14] Fix __qualname__ of __annotate__ functions in the interpreter

I'd still like to do #137842 on 3.15+, but that requires changing bytecode and we can't
really afford to do that in 3.14. So to fix this in 3.14, let's patch things up in the
ceval loop instead.

This is safe because the compiler only sets __annotate__ to just-created dedicated
annotate functions.
2026-04-15 21:52:43 -07:00
Miss Islington (bot)
e590f007ed
[3.14] gh-137335: remove a mktemp use in multiprocessing.connection to avoid security scanner noise (GH-148578) (#148583)
gh-137335: remove a mktemp use in multiprocessing.connection to avoid security scanner noise (GH-148578)

remove a mktemp use to avoid security scanner noise
(cherry picked from commit fd81246bd5)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
2026-04-14 17:06:25 -07:00
Miss Islington (bot)
b988157e87
[3.14] gh-148192: Fix Generator._make_boundary behavior with CRLF line endings. (GH-148193) (#148550)
The Generator._make_boundary regex did not match on boundary phrases correctly when using CRLF line endings due to re.MULTILINE not considering \r\n as a line ending.
(cherry picked from commit 4af46b4ab5)

Co-authored-by: Henry Jones <44321887+henryivesjones@users.noreply.github.com>
2026-04-14 12:04:50 -04:00
Miss Islington (bot)
314f12c015
[3.14] gh-148487: Fix issues in test_add_python_opts (GH-148507) (#148545)
gh-148487: Fix issues in `test_add_python_opts` (GH-148507)
(cherry picked from commit 44f1b987ed)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-14 10:12:42 +00:00
Miss Islington (bot)
adb2a3ac51
[3.14] gh-148508: Add resilience to SSL preauth tests on iOS (GH-148536) (#148539)
Adds handling for a test case seen in the iOS SSL tests where an SSL connection fails to
handshake correctly.
(cherry picked from commit c40e8b016a)

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
2026-04-14 12:41:37 +08:00
Miss Islington (bot)
d42874a1ba
[3.14] gh-148370: prevent quadratic behavior in configparser.ParsingError.combine (GH-148452) (#148532)
gh-148370: prevent quadratic behavior in `configparser.ParsingError.combine` (GH-148452)
(cherry picked from commit 2662db0c45)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-04-13 22:59:47 +00:00
Miss Islington (bot)
592c68cf6b
[3.14] gh-146139: Disable socketpair authentication on WASI (GH-146140) (#148526)
gh-146139: Disable `socketpair` authentication on WASI (GH-146140)

Calling `connect(2)` on a non-blocking socket on WASI may leave the socket in a
"connecting" but not yet "connected" state.  In the former case, calling
`getpeername(2)` on it will fail, leading to an unhandled exception in Python.
(cherry picked from commit a5b76d53bb)

Co-authored-by: Joel Dice <joel.dice@akamai.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Brett Cannon <brett@python.org>
2026-04-13 21:34:06 +00:00
Miss Islington (bot)
82ab8fb666
[3.14] tests: use errno.EBADF instead of hardcoded number in _close_file() (GH-148345) (#148410)
tests: use errno.EBADF instead of hardcoded number in _close_file() (GH-148345)

test_interpreters: use errno.EBADF instead of hardcoded number in _close_file()

Replace the hardcoded `9` check in `Lib/test/test_interpreters/utils.py` with `errno.EBADF`.

Using `errno.EBADF` makes the helper portable across platforms with different errno numbering while preserving the intended behavior.
(cherry picked from commit cef334fd4c)

Co-authored-by: Artem Yarulin <artem.yarulin@kapteko.com>
2026-04-12 18:13:14 -07:00
Miss Islington (bot)
942d3024b3
[3.14] gh-105936: Properly update closure cells for __setattr__ and __delattr__ in frozen dataclasses with slots (GH-144021) (#148469)
gh-105936: Properly update closure cells for `__setattr__` and `__delattr__` in frozen dataclasses with slots (GH-144021)
(cherry picked from commit 8a398bfbbc)

Co-authored-by: Prometheus3375 <prometheus3375@gmail.com>
Co-authored-by: Sviataslau <35541026+Prometheus3375@users.noreply.github.com>
2026-04-12 21:45:43 +00:00
Miss Islington (bot)
7ecd85c032
[3.14] gh-146313: Fix multiprocessing ResourceTracker deadlock after os.fork() (GH-146316) (#148425)
gh-146313: Fix multiprocessing ResourceTracker deadlock after os.fork() (GH-146316)

`ResourceTracker.__del__` (added in gh-88887 circa Python 3.12) calls
os.waitpid(pid, 0) which blocks indefinitely if a process created via os.fork()
still holds the tracker pipe's write end. The tracker never sees EOF, never
exits, and the parent hangs at interpreter shutdown.

Fix with two layers:

- **At-fork handler.** An os.register_at_fork(after_in_child=...)
  handler closes the inherited pipe fd in the child unless a preserve
  flag is set. popen_fork.Popen._launch() sets the flag before its
  fork so mp.Process(fork) children keep the fd and reuse the parent's
  tracker (preserving gh-80849). Raw os.fork() children close the fd,
  letting the parent reap promptly.

- **Timeout safety-net.** _stop_locked() gains a wait_timeout
  parameter. When called from `__del__`, it polls with WNOHANG using
  exponential backoff for up to 1 second instead of blocking
  indefinitely. The at-fork handler makes this unreachable in
  well-behaved paths; it remains for abnormal shutdowns.
(cherry picked from commit 3a7df632c9)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Co-authored-by: Itamar Oren <itamarost@gmail.com>
2026-04-12 10:08:23 -07:00
Miss Islington (bot)
a89b2419e0
[3.14] gh-148393: Use atomic ops on _ma_watcher_tag in free threading build (gh-148397) (#148451)
Fixes data races between dict mutation and watch/unwatch on the same dict.
(cherry picked from commit 3ab94d6842)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2026-04-12 15:05:34 +00:00
Miss Islington (bot)
af2f5189a1
[3.14] gh-146333: Fix quadratic regex backtracking in configparser option parsing (GH-146399) (#148287)
gh-146333: Fix quadratic regex backtracking in configparser option parsing (GH-146399)

Use negative lookahead in option regex to prevent backtracking, and to avoid changing logic outside the regexes (since people could use the regex directly).
(cherry picked from commit 7e0a0be409)

Co-authored-by: Joshua Swanson <22283299+joshuaswanson@users.noreply.github.com>
2026-04-12 00:05:10 +00:00
Miss Islington (bot)
4f8a77bf3f
[3.14] gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106) (#148404)
gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106)

When a custom iterator calls next() on the same csv.reader from
within __next__, the inner iteration sets self->fields to NULL.
The outer iteration then crashes in parse_save_field() by passing
NULL to PyList_Append.

Add a guard after PyIter_Next() to detect that fields was set to
NULL by a re-entrant call, and raise csv.Error instead of crashing.
(cherry picked from commit 20994b1809)

Co-authored-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
2026-04-11 22:46:26 +00:00
Miss Islington (bot)
e8f3f7668f
[3.14] gh-145831: email.quoprimime: decode() leaves stray \r when eol='\r\n' (GH-145832) (#148312)
decoded[:-1] only strips one character, leaving a stray \r when eol
is two characters. Fix: decoded[:-len(eol)].
(cherry picked from commit 1a0edb1fa8)

Co-authored-by: Stefan Zetzsche <120379523+stefanzetzsche@users.noreply.github.com>
2026-04-10 08:49:59 -04:00
Hugo van Kemenade
1f177749c5
[3.14] gh-148254: Use singular "sec" in timeit verbose output (GH-148290) (#148303)
Co-authored-by: gaweng <38250674+gaweng@users.noreply.github.com>
2026-04-09 15:17:55 +00:00
Miss Islington (bot)
f46a17b19f
[3.14] gh-70039: smtplib: store the server name in ._host in .connect() (GH-115259) (#148273)
Original patch by gigaplastik, extended with a few more tests.

Addresses gh-70039 and bpo-25852: failure of starttls if connect is called explicitly.
(cherry picked from commit 442f83a5ea)

Co-authored-by: nmartensen <nis.martensen@web.de>
2026-04-08 18:14:15 -04:00
Miss Islington (bot)
5df7652859
[3.14] gh-146458: Fix REPL height and width tracking on resize (GH-146459) (#148232)
gh-146458: Fix REPL height and width tracking on resize (GH-146459)
(cherry picked from commit 0b20bff386)

Co-authored-by: Gabriel Volles Marinho <147559808+GabrielvMarinho@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-04-07 21:37:46 +00:00
Hugo van Kemenade
23116f998f Python 3.14.4 2026-04-07 16:13:20 +03:00
Gregory P. Smith
25369a8c78
[3.14] gh-144503: Pass sys.argv to forkserver as real argv elements (GH-148194) (#148195)
Avoid embedding the parent's sys.argv into the forkserver -c command
string via repr().  When sys.argv is large (e.g. thousands of file
paths from a pre-commit hook), the resulting single argument could
exceed the OS per-argument length limit (MAX_ARG_STRLEN on Linux,
typically 128 KiB), causing posix_spawn to fail and the parent to
observe a BrokenPipeError.

Instead, append the argv entries as separate command-line arguments
after -c; the forkserver child reads them back as sys.argv[1:].  This
cannot exceed any limit the parent itself did not already satisfy.

Regression introduced by gh-143706 / 298d5440eb.
(cherry picked from commit 5e9d90b615)
2026-04-07 06:19:32 +00:00
Miss Islington (bot)
8f59d40244
[3.14] gh-137586: Open external osascript program with absolute path (GH-137584) (#148173)
Co-authored-by: Fionn <1897918+fionn@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-04-07 03:35:12 +00:00
Miss Islington (bot)
07158b605d
[3.14] gh-146613: Fix re-entrant use-after-free in itertools._grouper (GH-147962) (#148010)
gh-146613: Fix re-entrant use-after-free in `itertools._grouper` (GH-147962)
(cherry picked from commit fc7a188fe7)

Co-authored-by: Ma Yukun <68433685+TheSkyC@users.noreply.github.com>
2026-04-06 18:23:08 +03:00
Miss Islington (bot)
40a0a94700
[3.14] gh-148157: Check for _PyPegen_add_type_comment_to_arg fail in _PyPegen_name_default_pair (GH-148158) (#148162)
(cherry picked from commit 1795fccfbc)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-06 12:22:33 +00:00
Miss Islington (bot)
64207c930b
[3.14] gh-145883: Fix two heap-buffer-overflows in _zoneinfo (GH-145885) (#148087)
(cherry picked from commit fe9befc1ca)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-04 17:13:13 +01:00
Miss Islington (bot)
1c3e3fbcfb
[3.14] gh-143394: Skip pyrepl test_no_newline() basic REPL if readline is missing (GH-147973) (#148005)
gh-143394: Skip pyrepl test_no_newline() basic REPL if readline is missing (GH-147973)
(cherry picked from commit 97babb8ef7)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-04-04 08:38:43 +00:00
Russell Keith-Magee
ab3d37fab6
[3.14] gh-146541: Allow building the Android testbed for 32-bit targets (GH-146542) (#148064)
Allows building the Android testbed for 32-bit targets, adding the target triplets
`arm-linux-androideabi` and `i686-linux-android`.
(cherry picked from commit 848bbe9ff2)

Co-authored-by: Robert Kirkman <31490854+robertkirkman@users.noreply.github.com>
Co-authored-by: Malcolm Smith <smith@chaquo.com>
2026-04-04 03:58:20 +00:00
Miss Islington (bot)
594b5a05dc
[3.14] gh-143930: Tweak the exception message and increase test coverage (GH-146476) (GH-148042)
(cherry picked from commit 3681d47a44)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2026-04-03 18:28:52 +02:00
Miss Islington (bot)
25b48b84b8
[3.14] gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (GH-145901) (#147331)
gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (GH-145901)

The long_from_string_base() might return a small integer, when the
_pylong.py is used to do conversion.  Hence, we must be careful here to
not smash it "small int" bit by using the _PyLong_FlipSign().
(cherry picked from commit db5936c5b8)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-03-31 16:14:12 +02:00
Miss Islington (bot)
ed557e6a5f
[3.14] gh-146615: Fix crash in __get__() for METH_METHOD descriptors with invalid type argument (GH-146634) (GH-146647)
(cherry picked from commit 72d29ea363)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
2026-03-31 08:20:00 +00:00
Miss Islington (bot)
3c434f7f0f
[3.14] gh-146250: Fix memory leak in re-initialization of SyntaxError (GH-146251) (#146517)
Co-authored-by: Brij Kapadia <97006829+bkap123@users.noreply.github.com>
2026-03-30 16:14:58 +00:00
Miss Islington (bot)
7317e9d761
[3.14] gh-146556: Fix infinite loop in annotationlib.get_annotations() on circular __wrapped__ (GH-146557) (#146622)
gh-146556: Fix infinite loop in annotationlib.get_annotations() on circular __wrapped__ (GH-146557)
(cherry picked from commit 2cf6a68f02)

Co-authored-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
2026-03-29 22:30:14 -07:00
Miss Islington (bot)
1458ea0065
[3.14] gh-146090: fix memory management of internal sqlite3 callback contexts (GH-146569) (#146595)
gh-146090: fix memory management of internal `sqlite3` callback contexts (GH-146569)
(cherry picked from commit aa6680775d)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-03-29 15:15:05 +02:00