Commit graph

57134 commits

Author SHA1 Message Date
Miss Islington (bot)
77cc4428a7
[3.15] gh-146452: Fix pickle segfault on concurrent mutation of dict in pickle (GH-146470) (#150292)
gh-146452: Fix pickle segfault on concurrent mutation of dict in pickle (GH-146470)
(cherry picked from commit e62a61177f)

Co-authored-by: Farhan Saif <fsaif@uic.edu>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2026-05-23 07:33:21 +00:00
Miss Islington (bot)
3daf1fad7a
[3.15] gh-149189: Revert "Modern defaults for pprint (GH-149190)" (GH-150249) (#150268)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-05-22 20:49:36 +00:00
Miss Islington (bot)
f5231469b5
[3.15] gh-148829: Make sentinels' repr and module customizable (GH-149654) (#150092)
Implementation of python/peps#4968.
(cherry picked from commit 08218030a5)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-05-22 07:44:34 -07:00
Miss Islington (bot)
e192a0ea52
[3.15] gh-137571: Protect against possible UnboundLocalError in gzip._GzipReader.read() (GH-150222) (GH-150229)
This has not been observed in practice, but we cannot be 100% sure that
it will not happen with some weird gzip data.
(cherry picked from commit 28eac9a726)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-22 09:46:14 +00:00
Miss Islington (bot)
b039d1bd97
[3.15] gh-133998: Fix gzip file creation when time is out of range (GH-134278) (GH-150221)
(cherry picked from commit 1daad8a163)

Co-authored-by: adang1345 <adang1345@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-22 07:48:42 +00:00
Miss Islington (bot)
591c4ffdd9
[3.15] gh-149995: Update typing.py docstrings and documentation (GH-149996) (#150215)
gh-149995: Update typing.py docstrings and documentation (GH-149996)

Some of these docstrings read as if they were written when typing.py was
first written, and things have evolved since then.

A few motivations:
- Call protocols protocols instead of ABCs. They are also ABCs, but the fact
  they are protocols is more relevant to typing.
- Avoid recommending direct use of .__annotations__ and steer users to
  annotationlib instead.
- For TypedDict, mention NotRequired before total=False since it is more
  general and probably more frequently useful.
- For overloads, mention runtime use first instead of stub use. I think early on
  there was talk of allowing overload only in stubs, but it is now heavily used at
  runtime too and that's more likely to be relevant to users.
(cherry picked from commit f159419ae2)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-05-22 06:41:43 +00:00
Miss Islington (bot)
233cf75d6d
[3.15] gh-149819: fix .pth and .start file processing in subprocess when inheriting PYTHONPATH (GH-150177) (#150202)
gh-149819: fix .pth and .start file processing in subprocess when inheriting PYTHONPATH (GH-150177)

* gh-149819: Fix .pth files not loaded in Python subprocesses

After PR gh-149583 (Fix double evaluation of .pth and .site files in
venvs), .pth files are no longer loaded in subprocesses started with
subprocess.run([sys.executable, ...]).  The root cause: main() seeds
known_paths from removeduppaths() with all sys.path entries inherited
from the parent process.  addsitedir() then skips .pth processing for
every directory already in known_paths.

Fix:
- main(): call removeduppaths() for dedup but start known_paths as a
  fresh empty set, so that addsitedir() processes .pth files in every
  site-packages directory regardless of inherited sys.path.
- addsitedir(): move known_paths.add() before the sys.path.append and
  guard the append with 'sitedir not in sys.path' to avoid creating
  duplicate entries when called with a fresh known_paths.

This preserves the gh-75723 dedup guarantee while allowing subprocesses
to load .pth files.

* Fill out the tests for GH#149888

* Extend _make_start() and _make_pth() to take an optional `basedir` which is used instead of
 `site.tmpdir` if given.
* Add test_pth_processed_when_sitedir_already_on_path() to test the core GH#149819 bug: .pth files
  in subprocesses aren't handled if PYTHONPATH pointing to the .pth directory is inherited.
* Similarly add test_start_processed_when_sitedir_already_on_path() to verify that .start files in
  the same circumstances are also now processed.

* Update Lib/site.py



* Oops!  Remove redundant code

---------
(cherry picked from commit 3c298e2e38)

Co-authored-by: Barry Warsaw <barry@python.org>
Co-authored-by: BugBounty Mind <bugbounty-mind@deepseek.tui>
Co-authored-by: scoder <stefan_ml@behnel.de>
2026-05-21 15:31:41 -07:00
Miss Islington (bot)
e6e3b9f490
[3.15] gh-107398: Fix tarfile stream mode exception when process the file with the gzip extra field (GH-126304) (GH-150199)
(cherry picked from commit 65f99329ed)

Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-21 20:02:10 +00:00
Miss Islington (bot)
9d042ad9ae
[3.15] gh-149219: Test frozendict in Lib/test/test_crossinterp.py (GH-149220) (#150186)
gh-149219: Test `frozendict` in `Lib/test/test_crossinterp.py` (GH-149220)
(cherry picked from commit c35b0f2b62)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-21 15:22:24 +00:00
sobolevn
a56a271000
[3.15] gh-149981: Test lazy import corner cases with module-level __getattr__ (GH-149982) (#150185)
(cherry picked from commit 6dbf4ba403)
2026-05-21 09:53:00 +00:00
Miss Islington (bot)
ca0da94f09
[3.15] gh-134261: ZipFile - Don't rely on local time for reproducible builds & tests (GH-134264) (#150137)
gh-134261: ZipFile - Don't rely on local time for reproducible builds & tests (GH-134264)

---------
(cherry picked from commit 9dcf94e906)

Co-authored-by: Caleb <23644849+ctrlaltf2@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Emma Smith <emma@emmatyping.dev>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2026-05-20 19:49:13 +00:00
Miss Islington (bot)
61444f60a1
[3.15] gh-150146: Fix NULL dereference in _Py_subs_parameters (GH-150147) (#150153)
gh-150146: Fix NULL dereference in `_Py_subs_parameters` (GH-150147)
(cherry picked from commit f621ba16b7)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-20 13:55:30 +00:00
Miss Islington (bot)
9c2620964e
[3.15] gh-150034: Print JSONL filename when profiling finishes (GH-150035) (#150151) 2026-05-20 12:00:49 +00:00
Miss Islington (bot)
034c536d56
[3.15] gh-149584: Fix excessive overhead in the Tachyon profiler regarding the cache behavior (GH-149649) (#150152) 2026-05-20 11:59:10 +00:00
Miss Islington (bot)
7f29fa5032
[3.15] gh-149807: Fix hash(frozendict): compute (key, value) pair hash (GH-149841) (#150149)
gh-149807: Fix hash(frozendict): compute (key, value) pair hash (GH-149841)
(cherry picked from commit 244300162d)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-05-20 11:51:54 +00:00
Miss Islington (bot)
de401ef6a5
[3.15] gh-150114: Reduce memory usage of test_free_threading.test_iteration (gh-150115) (#150124)
Reduce NUMITEMS from 100000 to 5000. Peak RSS for the full
test_free_threading suite drops from ~850 MB to ~175 MB.

(cherry picked from commit 61f12211fc)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2026-05-19 22:05:19 +00:00
Dino Viehland
6847f4bc60
[3.15] gh-150052: Resolve un-loaded lazily loaded submodules via module.__getattr__ instead of publishing lazy values (#150055) 2026-05-19 21:23:30 +00:00
Miss Islington (bot)
021381759f
[3.15] gh-124111: Keep tests passing for Tcl prior to 9.0 (GH-150102)
Also disables the UWP build in CI, since it was breaking (and is no longer released).
(cherry picked from commit ec9ce3ee98)

Co-authored-by: Steve Dower <steve.dower@python.org>
2026-05-19 21:57:21 +01:00
Miss Islington (bot)
3227857de8
[3.15] gh-149945: Fix potential OOM for gzip with large header (GH-149979) (GH-150093)
Do not read the whole filename and comment to memory for calculating the CRC.
(cherry picked from commit 51a5715df9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-19 20:38:47 +00:00
Miss Islington (bot)
28f275f713
[3.15] gh-86533: Restore os.makedirs() ability to apply *mode* recursively (GH-150011) (#150036)
bpo-42367: Restore os.makedirs() and pathlib.mkdir() ability to apply *mode* recursively via a new parent_mode= keyword argument.
(cherry picked from commit 9770e32ce0)

+ Make Path.mkdir parent_mode tests umask-independent

test_mkdir_with_parent_mode, test_mkdir_parent_mode_deep_hierarchy and
test_mkdir_parent_mode_same_as_mode assert exact directory mode bits but
did not pin the process umask.  On buildbots running with a restrictive
umask (e.g. 0o077) the 0o755 leaf was masked down to 0o700, failing the
assertions.  Wrap them in os_helper.temp_umask(0o022), matching the
other umask-aware mkdir tests in this file.

---------

Co-authored-by: nessita <124304+nessita@users.noreply.github.com>
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-05-18 22:10:01 -07:00
Miss Islington (bot)
d36e08099d
[3.15] gh-149816: fix dict.clear() race on split-table dict with non-embedded values (GH-149914) (#150000)
gh-149816: fix `dict.clear()` race on split-table dict with non-embedded values (GH-149914)
(cherry picked from commit 1692854706)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2026-05-19 10:12:25 +05:30
Dino Viehland
94c8bac2cd
[3.15] gh-148587: Make sys.lazy_modules match PEP and keep internal lazy submodules tra… (#150014)
Make sys.lazy_modules match PEP and keep internal lazy submodules tracking internal
2026-05-18 17:53:54 -07:00
Miss Islington (bot)
84ea87cde0
[3.15] gh-149977: Fix extra output of -m test test_lazy_import (GH-149978) (#150016)
gh-149977: Fix extra output of `-m test test_lazy_import` (GH-149978)
(cherry picked from commit 6d5be4b1d6)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-18 19:24:06 +00:00
Miss Islington (bot)
bdc44c55a2
[3.15] gh-149916: Restore the commented out part of test_body_encode in test_email (GH-149917) (GH-149937)
(cherry picked from commit 1cbe035723)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-17 08:33:11 +00:00
Miss Islington (bot)
6136ad6801
[3.15] gh-142349: Add help("lazy") support (GH-149886) (#149889)
gh-142349: Add `help("lazy")` support (GH-149886)
(cherry picked from commit 8be3fb1b50)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-15 16:57:59 +00:00
Miss Islington (bot)
0e2184aca0
[3.15] gh-149786: Fixes venvlauncher builds on Windows free-threaded (GH-149847)
(cherry picked from commit 1c5fe21eb2)

Co-authored-by: Steve Dower <steve.dower@python.org>
2026-05-15 14:12:05 +00:00
Miss Islington (bot)
176d0f51cf
[3.15] gh-149801: Add IANA registered names and aliases with leading zeros (GH-149804) (GH-149870)
Like IBM00858, CP00858, IBM01140, CP01140.
(cherry picked from commit 20438866ae)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-15 15:08:15 +03:00
Miss Islington (bot)
cc624f74ba
[3.15] gh-148675: Use a string for ctypes cparam tag (GH-149778) (#149869)
gh-148675: Use a string for ctypes cparam tag (GH-149778)
(cherry picked from commit 3ecca22567)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-05-15 11:52:55 +00:00
Miss Islington (bot)
5dadc64673
[3.15] gh-87451: Apply CVE-2021-4189 PASV fix to ftplib.ftpcp() (GH-149648) (#149792)
gh-87451: Apply CVE-2021-4189 PASV fix to ftplib.ftpcp() (GH-149648)

ftpcp() called parse227() directly and passed the source server's
self-reported PASV IPv4 address to the target server's PORT command,
bypassing the CVE-2021-4189 fix that was applied only to FTP.makepasv().
A malicious source FTP server could use this to redirect the target
server's data connection to an arbitrary host:port (SSRF).

ftpcp() now uses the source server's actual peer address, honoring the
existing trust_server_pasv_ipv4_address opt-out, the same as makepasv().

Thanks to Qi Ding at Aurascape AI for the report. (GHSA-w8c5-q2xf-gf7c)
(cherry picked from commit eac4fe3b2c)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
2026-05-15 10:50:45 +00:00
Miss Islington (bot)
ed27363ddf
[3.15] gh-149144: Use decodeURIComponent() for UTF-8 support in js_output() (GH-149157) (GH-149846)
gh-149144: Use decodeURIComponent() for UTF-8 support in js_output() (GH-149157)
(cherry picked from commit 461b1d9631)

Co-authored-by: Seth Larson <seth@python.org>
2026-05-15 00:38:11 +02:00
Miss Islington (bot)
21909e898e
[3.15] gh-124111: Update Windows build to use Tcl/Tk 9.0.3 (GH-149842)
(cherry picked from commit c62c3710dc)

Co-authored-by: Zachary Ware <zach@python.org>
2026-05-14 13:49:29 -05:00
Miss Islington (bot)
6302a8f17a
[3.15] gh-148821: Add more tests for invalid XML encodings (GH-149820) (GH-149821)
(cherry picked from commit c6f7368157)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-14 10:37:11 +00:00
Barry Warsaw
45fc9acb8c
[3.15] gh-149504: Fix re-entrancy bug when .pth/.start file invokes site.add sitedir() (#149659) (#149799)
* gh-149504: Fix re-entrancy bug when .pth/.start file invokes site.addsitedir() (#149659)

* Add re-entrant tests for gh-149504
* Add end-to-end integration test coverage

This ensures that future whitebox internal test changes do not regress the
public surface semantics.

* Implement a state class to process .pth and .start files

By using this state class and managing implicit and explicit batching, we make it structurally
impossible to get bitten by re-entrant site startup processing.

Fixes #149504

(cherry picked from commit b162307d7f)

* Add myself back to CODEOWNERS
2026-05-13 15:45:39 -07:00
Miss Islington (bot)
b6503057b2
[3.15] gh-140550: Update xxlimited with 3.15 limited API (GH-142827) (GH-149785)
(cherry picked from commit fa81cd976a)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-05-14 00:00:29 +02:00
Miss Islington (bot)
fb3500466d
[3.15] gh-128110: Fix rfc2047 whitespace handling in email parser address headers (GH-130749) (#149787)
RFC 2047 Section 6.2 requires that "any 'linear-white-space' that
separates a pair of adjacent 'encoded-word's is ignored." The modern
header value parser correctly implements that for unstructured headers,
but had missed a case in structured headers. This could cause a parsed
address header to include extraneous spaces in a display-name.

Switch to @bitdancer's fix from review feedback. Recharacterize space
between ews as fws after parsing in get_phrase.

RDM: This fix is dependent on the fact that "subsequent" atoms will never have
leading whitespace because that's been consumed already. I don't think
it's worth adding extra code for the possibility of leading whitespace
because the parser won't produce it. It's a bit of parser fragility in the
face of code changes, but I think that's a minor concern given the
parser design (which is that it consumes whitespace greedily)
(cherry picked from commit 7a4c6dfb88)

Co-authored-by: Mike Edmunds <medmunds@gmail.com>
Co-authored-by: R David Murray <rdmurray@bitdance.com>
2026-05-13 16:26:42 -04:00
Miss Islington (bot)
bb7a539da2
[3.15] gh-149776: Skip UDP Lite tests if it's not supported (GH-149777) (#149780)
gh-149776: Skip UDP Lite tests if it's not supported (GH-149777)

Fix test_socket on Linux kernel 7.1 and newer: skip UDP Lite tests if
it's not supported.
(cherry picked from commit 3cfc249e11)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-05-13 15:36:27 +00:00
Miss Islington (bot)
1a639b8669
[3.15] gh-148821: Add more strict tests for XML encodings (GH-149765) (GH-149770)
Exclude encodings like 'utf-8-sig', 'iso2022-jp' and 'hz' from the list of
supported encodings.
(cherry picked from commit fa2afa64d9)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-13 11:10:30 +00:00
Miss Islington (bot)
37f3deb571
[3.15] bpo-45509: Check gzip headers for corrupted fields (GH-29028) (GH-149769)
Check the header checksum it the HCRC field is present.
(cherry picked from commit dd94457893)

Co-authored-by: Ruben Vorderman <r.h.p.vorderman@lumc.nl>
2026-05-13 10:54:10 +00:00
Miss Islington (bot)
a5f77a13fd
[3.15] gh-148829: Add PySentinel_CheckExact() (GH-149725) (#149766)
gh-148829: Add PySentinel_CheckExact() (GH-149725)
(cherry picked from commit 94df62542c)

Co-authored-by: scoder <stefan_ml@behnel.de>
2026-05-13 10:39:38 +00:00
Miss Islington (bot)
4e369c1dea
[3.15] gh-149701: Fully silence potential hash -r error (GH-149702) (GH-149757)
(cherry picked from commit cd6096887e)
2026-05-13 10:28:27 +01:00
Miss Islington (bot)
15a597e9ba
[3.15] gh-149642: Fix interaction between exec and lazy_imports=all (GH-149643) (#149749)
gh-149642: Fix interaction between exec and lazy_imports=all (GH-149643)
(cherry picked from commit 4087ff8599)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-05-13 03:36:32 +00:00
Miss Islington (bot)
8b73ce9ab8
[3.15] gh-149718: Aggregate same stack frames in Tachyon in some collectors (GH-149719) (#149747)
gh-149718: Aggregate same stack frames in Tachyon in some collectors (GH-149719)
(cherry picked from commit 76f2285341)

Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-05-13 01:30:22 +01:00
Miss Islington (bot)
e3fbcc3eac
[3.15] gh-149496: Fix MacOSTest.test_default regression when BROWSER env var is set (GH-149579) (#149745)
gh-149496: Fix MacOSTest.test_default regression when BROWSER env var is set (GH-149579)

gh-149496: Fix MacOSTest.test_default failing when BROWSER env var is set

MacOSTest.test_default calls webbrowser.get() and asserts it returns a
MacOS instance. When BROWSER is set in the environment (e.g. BROWSER=open,
a common macOS workaround for the old osascript-based implementation),
register_standard_browsers() registers a GenericBrowser as the preferred
browser instead, causing the assertion to fail.

This is a regression introduced in gh-137586, which added MacOSTest and
moved test_default into it from MacOSXOSAScriptTest. MacOSXOSAScriptTest
had an identical setUp() guard added in gh-131254 specifically to fix this
same failure. The guard was not carried over to MacOSTest.

Add setUp() to MacOSTest to unset BROWSER for the duration of each test,
restoring the isolation that was already established as the correct pattern
for macOS webbrowser tests.
(cherry picked from commit 45c47d26c2)

Co-authored-by: Jeff Lyon <146767590+secengjeff@users.noreply.github.com>
2026-05-12 21:25:21 +00:00
Miss Islington (bot)
670f982fbd
[3.15] gh-134837: Correct and improve base85 documentation for base64 and binascii modules (GH-145843) (GH-149742)
(cherry picked from commit e667d62f11)

Co-authored-by: David Huggins-Daines <dhd@ecolingui.ca>
2026-05-12 20:25:28 +00:00
deadlovelll
6a66005699
[3.15] gh-149694: Fix missing docstring on asyncio.iscoroutinefunction (#149696) 2026-05-12 22:52:36 +05:30
Miss Islington (bot)
d3b86111ef
[3.15] gh-149676: Fix hash(frozendict | frozendict) (GH-149675) (#149717)
gh-149676: Fix hash(frozendict | frozendict) (GH-149675)

Fix new_dict_impl() to properly initialize ma_hash on frozendict.
(cherry picked from commit f5fb491341)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-05-12 15:57:02 +02:00
Miss Islington (bot)
45c431a55d
[3.15] Update mypy to 2.1.0 (GH-149709) (#149711)
Update mypy to 2.1.0 (GH-149709)
(cherry picked from commit b546cc10f5)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-12 09:09:52 +00:00
Savannah Ostrowski
a8c420879e
[3.15] gh-149614 - Restore deepcopiability of argparse.ArgumentParser… (#149693)
[3.15] gh-149614 - Restore deepcopiability of argparse.ArgumentParser instances (GH-149617)
(cherry picked from commit fadd9bc14e)

Co-authored-by: David Ellis <ducksual@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2026-05-11 18:25:40 +00:00
Sam Gross
8297d50a63
[3.15] gh-145235: Make dict watcher API thread-safe for free-threaded builds (gh-145233) (#149690)
In free-threaded builds, concurrent calls to PyDict_AddWatcher, PyDict_ClearWatcher, PyDict_Watch, and PyDict_Unwatch can race on the shared callback array and the per-dict watcher tags. This change adds a mutex to serialize watcher registration and removal, atomic operations for tag updates, and atomic acquire/release synchronization for callback dispatch in _PyDict_SendEvent.

(cherry picked from commit 8a4895985f)

Co-authored-by: Alper <alperyoney@fb.com>
2026-05-11 14:23:39 -04:00
Miss Islington (bot)
b4f2e88203
[3.15] gh-112821: Fix rlcompleter failures on objects with descriptors (GH-149577) (#149656)
gh-112821: Fix rlcompleter failures on objects with descriptors (GH-149577)

* gh-112821: Fix rlcompleter failures on objects with descriptors

* Confirm no accesses
(cherry picked from commit f23a1837d7)

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2026-05-11 12:07:50 -04:00