Commit graph

54278 commits

Author SHA1 Message Date
Miss Islington (bot)
dad9bec4fa
[3.13] gh-84353: Preserve non-UTF-8 filenames when appending to ZipFile (GH-150091) (GH-150529)
Preserve non-UTF-8 filenames when appending to a ZipFile.

---------
(cherry picked from commit 24c6bbc92b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-05-27 18:21:14 +00:00
Miss Islington (bot)
a58c24d9fd
[3.13] gh-88726: Stop using non-standard charset names eucgb2312_cn and big5_tw in email (GH-149959) (GH-150493)
(cherry picked from commit 5e467f4331)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-27 10:53:08 +00:00
Miss Islington (bot)
98a9ccbe39
[3.13] gh-149571: Fix the C implementation of Element.itertext() (GH-149929) (GH-150511)
It no longer emits text for comments and processing instructions.
(cherry picked from commit 7de4fcd445)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-27 10:49:54 +00:00
Miss Islington (bot)
43f71b0005
[3.13] gh-150175: Fix ThreadingMock call_count race condition (GH-150176) (#150180)
gh-150175: Fix ThreadingMock call_count race condition (GH-150176)

ThreadingMock._increment_mock_call() was not thread-safe.
Multiple threads calling the mock simultaneously could lose
increments due to race conditions on call_count and other
attributes.

Fix by overriding _increment_mock_call in ThreadingMixin
and wrapping it with the existing _mock_calls_events_lock.
(cherry picked from commit 388e023fe1)

Co-authored-by: saisneha196 <156835592+saisneha196@users.noreply.github.com>
2026-05-26 12:47:20 -07:00
Serhiy Storchaka
96d66ac33b
[3.13] gh-150285: Fix too long docstrings in the io module (GH-150287) (GH-150458) (GH-150470)
(cherry picked from commit 36137e46a8)
(cherry picked from commit 160dc74122)
2026-05-26 10:29:28 +00:00
Serhiy Storchaka
59cafbbeaf
[3.13] gh-150285: Fix too long docstrings in the curses module (GH-150286) (GH-150457) (GH-150469)
(cherry picked from commit e7f1216204)
(cherry picked from commit 4c0fe2d134)
2026-05-26 09:58:11 +00:00
Miss Islington (bot)
9463c9d33e
[3.13] gh-150285: Fix too long docstrings in the decimal module (GH-150288) (GH-150460) (GH-150465)
(cherry picked from commit 9d79e71fb6)
(cherry picked from commit 6bed57a3b6)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-26 12:49:41 +03:00
Miss Islington (bot)
20805238e5
[3.13] gh-80198: Improve test_pwd and test_grp (GH-150380) (GH-150398) (GH-150423)
Fix tests for non-existing names and ids when getpwall()/getgrall()
don't return all users/groups.

Add tests for out-of-range uids, integer float ids, bytes names,
null-terminated names, names with surrogates, empty names, excessive
arguments.
(cherry picked from commit 4bdff2cc89)
(cherry picked from commit 46e8f7a9e7)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-25 19:10:25 +00:00
Miss Islington (bot)
60d843777c
[3.13] gh-149449: Fix use-after-free in _PyUnicode_GetNameCAPI (GH-150323) (#150354)
gh-149449: Fix use-after-free in `_PyUnicode_GetNameCAPI` (GH-150323)
(cherry picked from commit 43c60ec2fd)

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2026-05-25 16:10:48 +05:30
Miss Islington (bot)
effcfd725d
[3.13] gh-145896: Fix typos and stale docstrings in the traceback module (GH-145897) (GH-150384)
(cherry picked from commit 832afeddce)

Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
2026-05-25 10:07:38 +00:00
Bénédikt Tran
e102378eca
[3.13] gh-142516: fix reference leaks in ssl.SSLContext objects (GH-143685) (GH-145075) (#148371)
Cherry picked from commits 3a2a686cc4
and 1decc7ee20 with minor amendments.
2026-05-24 11:43:03 +02:00
Hai Zhu
5d03b24827
[3.13] gh-148450: abc.register needs to update type_version when tp_flags is changed (GH-148623) (#150307) 2026-05-23 17:20:16 +05:30
Miss Islington (bot)
46cff6be90
[3.13] gh-137571: Protect against possible UnboundLocalError in gzip._GzipReader.read() (GH-150222) (GH-150231)
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:37:57 +00:00
Jelle Zijlstra
1df755c135
[3.13] gh-149995: Update typing.py docstrings and documentation (#150217)
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)
2026-05-22 05:09:41 +00:00
Miss Islington (bot)
cfa3daa7fe
[3.13] gh-107398: Fix tarfile stream mode exception when process the file with the gzip extra field (GH-126304) (GH-150201)
(cherry picked from commit 65f99329ed)

Co-authored-by: Nadeshiko Manju <me@manjusaka.me>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-21 22:38:54 +03:00
sobolevn
32feeff72d
[3.13] gh-150146: Fix NULL dereference in _Py_subs_parameters (GH-150147) (#150155)
* [3.13] 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 14:04:17 +00:00
Shamil
e87baa8d24
[3.13] gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851) (#150079)
gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851)

User callbacks invoked during JSON encoding (e.g. the `default` callback or
a custom string encoder) can mutate or clear the dict or sequence being
encoded, invalidating borrowed references to items, keys, and values. Hold
strong references unconditionally while iterating.



(cherry picked from commit 235fa7244a)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-05-19 20:33:22 -07:00
Miss Islington (bot)
9e071c9b28
[3.13] gh-146211: Reject CR/LF in HTTP tunnel request headers (GH-146212) (#148343)
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-05-18 19:44:36 +02:00
Miss Islington (bot)
b2b35bad02
[3.13] gh-149916: Restore the commented out part of test_body_encode in test_email (GH-149917) (GH-149939)
(cherry picked from commit 1cbe035723)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-17 08:29:33 +00:00
Miss Islington (bot)
e90f3baf5d
[3.13] gh-134837: Correct and improve base85 documentation for base64 module (GH-145843) (GH-149743) (GH-149893)
(cherry picked from commit e667d62f11)
(cherry picked from commit 9ad8a1b955)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: David Huggins-Daines <dhd@ecolingui.ca>
2026-05-15 21:36:47 +03:00
Miss Islington (bot)
012530ba4f
[3.13] gh-149801: Add IANA registered names and aliases with leading zeros (GH-149804) (GH-149872)
Like IBM00858, CP00858, IBM01140, CP01140.
(cherry picked from commit 20438866ae)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-15 15:08:50 +03:00
Miss Islington (bot)
a6ebca755c
[3.13] gh-148821: Add more tests for invalid XML encodings (GH-149820) (GH-149823)
(cherry picked from commit c6f7368157)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-14 10:34:45 +00:00
Miss Islington (bot)
82db654e13
[3.13] gh-128110: Fix rfc2047 whitespace handling in email parser address headers (GH-130749) (#149789)
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:29:07 -04:00
Miss Islington (bot)
bb3446dda6
[3.13] gh-87451: Apply CVE-2021-4189 PASV fix to ftplib.ftpcp() (GH-149648) (#149794)
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-13 17:58:26 +00:00
Miss Islington (bot)
49d08674d8
[3.13] gh-149776: Skip UDP Lite tests if it's not supported (GH-149777) (#149782)
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:27:56 +00:00
Miss Islington (bot)
4e2cf29607
[3.13] gh-148821: Add more strict tests for XML encodings (GH-149765) (GH-149772)
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:05:06 +00:00
Miss Islington (bot)
9e220bbfeb
[3.13] gh-149701: Fully silence potential hash -r error (GH-149702) (GH-149759)
(cherry picked from commit cd6096887e)
2026-05-13 09:22:02 +01:00
Miss Islington (bot)
d36f61d8c8
[3.13] Update mypy to 2.1.0 (GH-149709) (#149713)
Update mypy to 2.1.0 (GH-149709)
(cherry picked from commit b546cc10f5)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-12 09:06:58 +00:00
Miss Islington (bot)
5ad22a8de6
[3.13] gh-112821: Fix rlcompleter failures on objects with descriptors (GH-149577) (#149658)
* 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>

* Add missing import

---------

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
Co-authored-by: Michael Droettboom <mdroettboom@nvidia.com>
2026-05-11 12:08:20 -04:00
Miss Islington (bot)
a42082b6a1
[3.13] gh-146061: Clarify indent=None in json docs (GH-146095) (GH-149669)
(cherry picked from commit 833dae7c1f)

Co-authored-by: Jonathan Dung <jonathandung@yahoo.com>
2026-05-11 11:38:56 +00:00
Miss Islington (bot)
0478bd83d8
[3.13] gh-149486: tarfile.data_filter: validate written link target (GH-149487) (GH-149555)
* gh-149486: tarfile.data_filter: validate written link target (GH-149487)

The data filter rewrote linknames with normpath() but ran the
containment check against the un-normalised value, and computed a
symlink's directory before stripping trailing slashes.  Both let a
crafted archive create links pointing outside the destination.  Also
reject link members that resolve to the destination directory itself,
which could otherwise replace it with a symlink and redirect all
subsequent members.

(Patch by Greg; Petr's just reviewing & merging.)
(cherry picked from commit 578411982c)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-05-11 11:58:26 +02:00
Miss Islington (bot)
6ab65b3e7e
[3.13] gh-149388: Make asyncio PipeHandle.close idempotent (GH-149518) (#149607)
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:09 +05:30
Miss Islington (bot)
ba894f1767
[3.13] gh-79638: Test other HTTP error codes besides 403 in test_robotparser (GH-149569) (GH-149582)
Also, use urllib.request.urlcleanup() in NetworkTestCase.
(cherry picked from commit 57ef219950)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-08 20:46:14 +00:00
Miss Islington (bot)
05956df2c2
[3.13] gh-148390: fix undefined behavior of memoryview(...).cast("?") (GH-148454) (GH-149299)
(cherry picked from commit 69e0a78e6e)
(cherry picked from commit 454401c8e9)

Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-05-08 17:50:00 +02:00
Miss Islington (bot)
59b260c61b
[3.13] gh-149096: Remove 'im_*' attribute reference from inspect module docstring (GH-149108) (#149440)
gh-149096: Remove  'im_*' attribute reference from inspect module docstring (GH-149108)

The im_class/func/self names were removed in 3.0.  The prefix appears nowhere else in inspect.py
and nowhere in inspect.rst.
(cherry picked from commit e4444538dc)

Co-authored-by: Vineet Kumar <108144301+whyvineet@users.noreply.github.com>
2026-05-06 02:52:33 +00:00
Miss Islington (bot)
99c9b85ad8
[3.13] gh-149410: Test that typing.NoDefault is final (GH-149411) (#149420)
gh-149410: Test that `typing.NoDefault` is final (GH-149411)
(cherry picked from commit bad9296fb0)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-05 15:22:48 +00:00
Miss Islington (bot)
67c47ce163
[3.13] gh-149403: Fix NameError in Lib/test/test_capi/test_getargs.py (GH-149404) (#149407)
gh-149403: Fix `NameError` in `Lib/test/test_capi/test_getargs.py` (GH-149404)
(cherry picked from commit 114781040c)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-05-05 14:47:46 +03:00
Savannah Ostrowski
a02beabe2d
[3.13] GH-130750: Restore quoting of choices in argparse error messag… (#149386)
[3.13] GH-130750: Restore quoting of choices in argparse error messages to match documentation and improve clarity (GH-144983)
(cherry picked from commit 53a7f76501)
2026-05-04 23:18:05 +00:00
Miss Islington (bot)
9f9a273267
[3.13] gh-149377: update bundled pip to 26.1.1 (GH-149378) (#149380)
gh-149377: update bundled pip to 26.1.1 (GH-149378)
(cherry picked from commit de66149f66)

Co-authored-by: Stéphane Bidoul <stephane.bidoul@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2026-05-04 23:43:33 +03:00
Serhiy Storchaka
561d1b95b9
[3.13] gh-138907: Support RFC 9309 in robotparser (GH-138908) (GH-149376)
* 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

(cherry picked from commit bc285e5832)
2026-05-04 18:43:03 +00:00
Miss Islington (bot)
023ecbd01f
[3.13] gh-148093: Raise binascii.Error from binascii.a2b_uu() on empty input (GH-149077) (GH-149349)
Instead of reading past the end of the empty buffer.
(cherry picked from commit 0c6d2f64c0)

Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-05-04 10:06:25 +00:00
Miss Islington (bot)
6a2f12b031
[3.13] gh-148663: Document that calendar.IllegalMonthError inherits from both ValueError and IndexError (GH-148664) (#148918)
(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-05-03 17:42:39 +01:00
Miss Islington (bot)
302ef2122c
[3.13] gh-148914: Fix memoization of in-band PickleBuffer in the Python implementation (GH-149052) (GH-149275)
Previously, identical PickleBuffers did not preserve identity.
Also, empty writable PickleBuffer memoized an empty bytearray object
in place of b'' which is a singleton in CPython, so the following
references to b'' were unpickled as an empty bytearray object.
(cherry picked from commit b89735625d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-02 11:11:15 +00:00
Miss Islington (bot)
bb2c05b398
[3.13] gh-149117: Set ImportError.name on errors from runpy.run_module/run_path (gh-149159) (#149258)
gh-149117: Set `ImportError.name` on errors from `runpy.run_module`/`run_path` (gh-149159)

Set ImportError.name on errors from runpy.run_module/run_path

`runpy.run_module()` and `runpy.run_path()` now set the `name` attribute
of the `ImportError` they raise to the requested module name, matching
the behaviour of a regular import statement (previously `name` was
always `None`, which broke introspection).

The `name=` kwarg is gated on `issubclass(error, ImportError)` because
`_get_module_details()` is also used by `_run_module_as_main()` with
a private `_Error` sentinel class. `_Error` does not subclass
ImportError, and `BaseException.__init__` rejects unknown kwargs at
the C level, so passing `name=` unconditionally would break the
`python -m foo` codepath.
(cherry picked from commit ff35fe4633)

Co-authored-by: W. H. Wang <mattwang44@gmail.com>
2026-05-02 02:51:06 +00:00
Miss Islington (bot)
104a38c495
[3.13] gh-148518 fix index error in local part attribute (GH-148522) (#149199)
As part of fixing bpo-27931 code was introduced to get_bare_quoted_string
that added an empty Terminal if the quoted string was empty.  This isn't
the best answer in terms of the parse tree; we really want the token
list to be empty in that case.  But having it be empty resulted in
local_part raising the index error.  We find that same problem if we
try to parse an address consisting of a single dquote.  By fixing
local_part to not raise on an empty token list, we can have the
bare_quoted_string code correctly return an empty token list for
the empty string cases (two dquotes or a single dquote as the
entire addrespec, at the end of a line).
(cherry picked from commit bdbb55c403)

Co-authored-by: R. David Murray <rdmurray@bitdance.com>
2026-04-30 18:13:27 -04:00
Miss Islington (bot)
b3e0c72fa4
[3.13] bpo-39100: _header_value_parser: do not treat a Group as invalid-mailbox (GH-24872) (#149192)
When an address in an address-list has garbage at the end, the code will
currently:

1. change the mailbox in the last parsed address into invalid-mailbox by
   overriding its token_type;
2. wrap the trailing garbage into another invalid-mailbox and append it
   to the last parsed address.

However, that does not take into account that an address may
also contain a Group instead of a single mailbox. In that case,
overwriting token_type leads to undesirable results, e.g. parsing an
email with the following 'To' header:

unlisted-recipients:; (no To-header on input)

raises an AttributeError from trying to treat the Group as a Mailbox.

Moreover it is questionable whether the previously parsed mailbox should
be treated as invalid in addition to the trailing garbage.

Address both of the above by wrapping the trailing garbage in a new
Address with a single invalid-mailbox, and append it to the AddressList
directly.

Changes the results of the
test_get_address_list_mailboxes_invalid_addresses test, where the
address list is now parsed into 4 mailboxes instead of 3 (all but the
first one are invalid).
(cherry picked from commit b413bc7a1f)

Co-authored-by: elenril <anton@khirnov.net>
2026-04-30 14:15:43 -04:00
Miss Islington (bot)
d424d8847a
[3.13] gh-149148: Upgrade bundled pip to 26.1 (GH-149150) (#149155)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-04-29 14:53:55 +00:00
Miss Islington (bot)
c1fb21b150
[3.13] gh-97032: avoid test_squeezer crash on macOS buildbots (gh-115508) (GH-148141) (#148415)
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
Co-authored-by: Ned Deily <nad@python.org>
2026-04-29 13:01:04 +03:00
Miss Islington (bot)
d6d68494be
[3.13] gh-148169: Fix webbrowser %action substitution bypass of dash-prefix check (GH-148170) (#148517)
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-29 13:00:10 +03:00
Miss Islington (bot)
0c83e503cd
[3.13] gh-140287: Handle PYTHONSTARTUP script exceptions in the asyncio REPL (GH-140288) (#148988)
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2026-04-29 12:57:19 +03:00