Commit graph

5873 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
Victor Stinner
795dd3bd35
[3.15] Revert "[3.15] gh-146452: Improve locking granularity in pickle's batch_dict_exact and fix race condition (GH-150025) (#150039)" (#150262)
Revert "[3.15] gh-146452: Improve locking granularity in pickle's batch_dict_exact and fix race condition (GH-150025) (#150039)"

This reverts commit 66ade2861f.
2026-05-23 12:27:27 +05:30
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)
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)
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)
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)
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)
66ade2861f
[3.15] gh-146452: Improve locking granularity in pickle's batch_dict_exact and fix race condition (GH-150025) (#150039)
gh-146452: Improve locking granularity in pickle's batch_dict_exact and fix race condition (GH-150025)

Remove assertion that could fail in rare race condition.

Replace the coarse critical section wrapping the entire function with
fine-grained sections covering only PyDict_Next + Py_INCREF.
Also handle PyDict_Next returning 0 in the single-item fast path.
(cherry picked from commit 57a0e570d3)

Co-authored-by: Saul Cooperman <58375603+scopreon@users.noreply.github.com>
2026-05-18 23:53:57 +00:00
Miss Islington (bot)
01b07df858
[3.15] gh-149816: Fix a RC in _random.Random.__init__ method (GH-149824) (#149997)
gh-149816: Fix a RC in `_random.Random.__init__` method (GH-149824)
(cherry picked from commit 14af19e6c0)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-18 16:16:55 +00:00
Miss Islington (bot)
42ff9b4959
[3.15] gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (GH-149922) (#149943)
gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (GH-149922)
(cherry picked from commit acefff95ea)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2026-05-17 11:01:15 +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)
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
Petr Viktorin
ff6f921ffa
[3.15] gh-149231: Revert extra NEWS entry (GH-149840)
gh-149231: Revert extra NEWS entry

This reverts commit dc7cad2f5d.
2026-05-14 19:16:23 +02:00
Miss Islington (bot)
dc7cad2f5d
[3.15] gh-149231: tomllib: Limit the number of parts in a key (GH-149233) (GH-149677)
(cherry picked from commit bc7c102f34)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-05-14 01:24:29 +02: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)
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)
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)
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)
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
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
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
Miss Islington (bot)
1162834c0e
[3.15] gh-139489: Add is_valid_text to xml.__all__ (GH-149641) (#149652)
gh-139489: Add is_valid_text to xml.__all__ (GH-149641)
(cherry picked from commit b45319e132)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-05-10 21:11:04 +00:00
Miss Islington (bot)
46a54ea5b0
[3.15] gh-148441: Avoid integer overflow in Expat's CharacterDataHandler (GH-148904) (#149639)
gh-148441: Avoid integer overflow in Expat's CharacterDataHandler (GH-148904)
(cherry picked from commit bc1be4f617)

Co-authored-by: ByteFlow <fakeshadow1337@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-05-10 14:11:57 +00:00
Miss Islington (bot)
212e996cba
[3.15] gh-149388: Make asyncio PipeHandle.close idempotent (GH-149518) (#149605)
gh-149388: Make asyncio `PipeHandle.close` idempotent (GH-149518)
(cherry picked from commit 7241f2739c)

Co-authored-by: Max Schmitt <max@schmitt.mx>
2026-05-09 20:38:34 +05:30
Hugo van Kemenade
f31a89bb90 Python 3.15.0b1 2026-05-07 16:26:31 +03:00
Jelle Zijlstra
ff422bd1c1
gh-141560: Add annotation_format parameter to getfullargspec (#149457) 2026-05-06 12:00:56 -07:00
David Ellis
8cad740557
gh-148823: Avoid importing _colorize when creating an ArgumentParser (#148827)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2026-05-06 18:24:18 +00:00
Alexis Dauphin
947c8ea3bc
gh-148599: Update WSA socket error codes (#148033) 2026-05-06 19:52:23 +02:00
Hugo van Kemenade
7cea70e14d
gh-144384: Lazily import _colorize (#149318) 2026-05-06 16:07:43 +00:00
Bénédikt Tran
7b6c248d61
gh-142307: deprecate legacy support for altering IMAP4.file (#142335)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-05-06 17:41:26 +03:00
Serhiy Storchaka
a5c7a74418
gh-139489: Add xml.is_valid_text() (GH-149412) 2026-05-06 14:40:10 +00:00
Jeff Lyon
aeb02ac42b
gh-137586: Replace 'osascript' with 'open' on macOS in webbrowser (#146439)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-05-06 16:56:17 +03:00
Shrey Naithani
970b0433f4
gh-148615: Handle -- separator in pdb argument parsing (#148624) 2026-05-05 21:22:58 -07:00
Hugo van Kemenade
426f99cb71
gh-149189: Modern defaults for pprint (#149190) 2026-05-05 15:04:05 +03:00
Tian Gao
ddfdf9b8df
gh-145378: Generate consistent colors for pdb commands (#149305) 2026-05-05 01:25:45 -07:00
Serhiy Storchaka
a76d9573e4
gh-139489: Add xml.is_valid_name() (GH-139768)
It allows to check whether a string can be used as an element or attribute
name in XML.
2026-05-05 11:25:22 +03:00
Tomas R.
ed99680487
gh-130472: Use fancycompleter in import completions (#148188) 2026-05-05 01:36:43 +00:00
Maurycy Pawłowski-Wieroński
c266f0c375
gh-149009: Validate thread_count in profiling.sampling binary reader (#149147) 2026-05-05 00:50:06 +00:00
Maurycy Pawłowski-Wieroński
04ce318522
gh-146256: Add --jsonl collector to the profiling.sampling (#146257) 2026-05-05 00:44:37 +00:00
Maurycy Pawłowski-Wieroński
6f8c964dc0
gh-149342: _remote_debugging: Fix binary profile corruption when sampling a (temporarily) empty stack (#149343) 2026-05-05 00:32:06 +00:00
Hugo van Kemenade
ffe050ad9b
gh-142389: Add support for backtick colorisation in argparse help text (#149375)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2026-05-04 22:58:04 +00:00
Hugo van Kemenade
ef6f0635ce
gh-142389: Add backticks to stdlib argparse help to display in colour (#149384)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
2026-05-04 22:23:18 +00:00
Savannah Ostrowski
53a7f76501
GH-130750: Restore quoting of choices in argparse error messages to match documentation and improve clarity (#144983) 2026-05-04 21:51:48 +00:00
Matt Van Horn
7acee984e8
gh-146406: Add cross-language method suggestions for builtin AttributeError (#146407)
When Levenshtein-based suggestions find no match for an AttributeError
on list, str, or dict, check a static table of common method names from
JavaScript, Java, C#, and Ruby.

For example, [].push() now suggests .append(), "".toUpperCase() suggests
.upper(), and {}.keySet() suggests .keys().

The list.add() case suggests using a set instead of suggesting .append(),
since .add() is a set method and the user may have passed a list where
a set was expected (per discussion with Serhiy Storchaka, Terry Reedy,
and Paul Moore).

Design: flat (type, attr) -> suggestion text table, no runtime
introspection. Only exact builtin types are matched to avoid false
positives on subclasses.

Discussion: https://discuss.python.org/t/106632

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-04 21:38:07 +00:00
Stéphane Bidoul
de66149f66
gh-149377: update bundled pip to 26.1.1 (#149378)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2026-05-04 19:58:28 +00:00
Pablo Galindo Salgado
12a20daee7
gh-149321: Fix stdlib imports with lazy imports disabled (#149338) 2026-05-04 19:03:21 +01:00
Serhiy Storchaka
bc285e5832
gh-138907: Support RFC 9309 in robotparser (GH-138908)
* empty lines are always ignored instead of separating groups
* the "user-agent" line after a rule starts a new group
* groups matching the same user agent are now merged
* the rule with the longest match wins instead of the first matching rule
* in case of equal matches, the “Allow” rule wins over “Disallow”
* special characters “$” and “*” are now supported in rules
* prefer full match for user agent
2026-05-04 18:03:11 +00:00