Commit graph

32641 commits

Author SHA1 Message Date
Miss Islington (bot)
a0a1aa3125
[3.13] gh-135335: flush stdout/stderr in forkserver after preloading modules (GH-135338) (#135671)
gh-135335: flush stdout/stderr in forkserver after preloading modules (GH-135338)

If a preloaded module writes to stdout or stderr, and the stream is buffered,
child processes will inherit the buffered data after forking. Attempt to
prevent this by flushing the streams after preload.
(cherry picked from commit 9877d191f4)

Co-authored-by: Duane Griffin <duaneg@dghda.com>
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-06-18 12:40:21 +00:00
Miss Islington (bot)
28a70a59e4
[3.13] gh-135489: Show verbose output for failing tests during PGO profiling step with --enable-optimizations (#135600)
Co-authored-by: PuQing <me@puqing.work>
2025-06-17 01:47:27 -04:00
Sam Gross
f33a5e891a
[3.13] gh-132617: Fix dict.update() mutation check (gh-134815) (gh-135582)
Use `ma_used` instead of `ma_keys->dk_nentries` for modification check
so that we only check if the dictionary is modified, not if new keys are
added to a different dictionary that shared the same keys object.
(cherry picked from commit d8994b0a77)
2025-06-16 17:30:52 +00:00
Miss Islington (bot)
404e8aa9f3
[3.13] gh-132969: Fix error/hang when shutdown(wait=False) and task exited abnormally (GH-133222) (GH-135343)
gh-132969:  Fix error/hang when shutdown(wait=False) and task exited abnormally (GH-133222)

When shutdown is called with wait=False, the executor thread keeps running
even after the ProcessPoolExecutor's state is reset. The executor then tries
to replenish the worker processes pool resulting in an error and a potential hang
when it comes across a worker that has died. Fixed the issue by having
_adjust_process_count() return without doing anything if the ProcessPoolExecutor's
state has been reset.

Added unit tests to validate two scenarios:
max_workers < num_tasks (exception)
max_workers > num_tasks (exception + hang)
(cherry picked from commit 598aa7cc98)

Co-authored-by: Ajay Kamdar <140011370+ogbiggles@users.noreply.github.com>
2025-06-16 14:08:03 +02:00
Miss Islington (bot)
3bd2818664
[3.13] gh-67022: Document bytes/str inconsistency in email.header.decode_header() and suggest email.headerregistry.HeaderRegistry as a sane alternative (GH-92900) (#135549)
gh-67022: Document bytes/str inconsistency in email.header.decode_header() and suggest email.headerregistry.HeaderRegistry as a sane alternative (GH-92900)

* gh-67022: Document bytes/str inconsistency in email.header.decode_header()

This function's possible return types have been surprising and error-prone
for the entirety of its Python 3.x history. It can return either:

1. `typing.List[typing.Tuple[bytes, typing.Optional[str]]]` of length >1
2. or `typing.List[typing.Tuple[str, None]]`, of length exactly 1

This means that any user of this function must be prepared to accept either
`bytes` or `str` for the first member of the 2-tuples it returns, which is a
very surprising behavior in Python 3.x, particularly given that the second
member of the tuple is supposed to represent the charset/encoding of the
first member.

This patch documents the behavior of this function, and adds test cases
to demonstrate it.

As discussed in bpo-22833, this cannot be changed in a backwards-compatible
way, and some users of this function depend precisely on the existing
behavior.

Add warnings about obsolescence of 'email.header.decode_header' and 'email.header.make_header' functions.

Recommend use of `email.headerregistry.HeaderRegistry` instead, as suggested
in https://github.com/python/cpython/pull/92900#discussion_r1112472177
(cherry picked from commit 60181f4ed0)

Co-authored-by: Dan Lenski <dlenski@gmail.com>
2025-06-15 16:02:43 -04:00
GiGaGon
a43cf1074a
[3.13] gh-135496: Fix f string exclamation mark error typo (GH-135495) (#135501) 2025-06-14 11:00:14 +03:00
Mikhail Efimov
e753a7c5f0
[3.13] gh-125723: Fix crash with f_locals when generator frame outlive their generator (GH-135453)
Backport of 8e20e42cc6 from GH-126956

Closes GH-125723
2025-06-14 04:08:03 +10:00
Tan Long
22cf289539
[3.13] gh-133439: Fix dot commands with trailing spaces are mistaken for multi-line sqlite statements in the sqlite3 command-line interface (GH-133440) (GH-133765)
(cherry picked from commit ebd4881db2)
2025-06-13 20:40:24 +03:00
Miss Islington (bot)
4455cbabf9
[3.13] gh-135462: Fix quadratic complexity in processing special input in HTMLParser (GH-135464) (GH-135482)
End-of-file errors are now handled according to the HTML5 specs --
comments and declarations are automatically closed, tags are ignored.
(cherry picked from commit 6eb6c5dbfb)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-13 17:20:30 +00:00
T. Wouters
6ae51582a1
[3.13] GH-135171: Roll back all fixes for GH-127682 as they are not suitable for 3.13 (#135390) 2025-06-11 16:57:35 +02:00
Miss Islington (bot)
5f5b173cc7
[3.13] gh-132415: Update vendored setuptools in `Lib/test/wheeldata` (GH-132887) (#135391)
(cherry picked from commit c9f3f5b4ed)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-06-11 14:55:14 +00:00
Miss Islington (bot)
871adc8e9f
[3.13] gh-135321: Always raise a correct exception for BINSTRING argument > 0x7fffffff in pickle (GH-135322) (GH-135383)
(cherry picked from commit 2b8b4774d2)

Co-authored-by: Justin Applegate <70449145+Legoclones@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-11 14:00:59 +03:00
Miss Islington (bot)
ffeaeaf660
[3.13] gh-133967: Do not normalize locale name 'C.UTF-8' to 'en_US.UTF-8' (GH-135347) (GH-135350)
(cherry picked from commit 0f866cbfef)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-11 12:43:38 +03:00
Serhiy Storchaka
37027ab535
[3.13] gh-135326: Restore support of __index__ in random.getrandbits() (#135332) 2025-06-10 12:41:10 +02:00
Miss Islington (bot)
f0d48b2bea
[3.13] gh-135276: Refresh zipfile.Path from zipp 3.23 (GH-135277) (#135279)
* gh-135276: Refresh `zipfile.Path` from zipp 3.23 (GH-135277)

Apply changes from zipp 3.23
(cherry picked from commit 8d6eb0c262)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>

* Removed features slated for Python 3.15 only.

---------

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2025-06-08 17:56:35 -04:00
Miss Islington (bot)
e5d1771c6b
[3.13] gh-134151 Fix TypeError in email.utils.decode_params when sorting RFC 2231 continuations (GH-134687) (#135248)
gh-134151 Fix `TypeError` in `email.utils.decode_params` when sorting RFC 2231 continuations (GH-134687)

- Fix sorting logic in `email.utils.decode_params` to handle None values.
- Update tests for RFC 2231 continuation sorting.
(cherry picked from commit bcb6b45cb8)

Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
2025-06-08 07:38:00 +00:00
Miss Islington (bot)
58b9581ff5
[3.13] gh-134155: fix AttributeError in email._header_value_parser.get_address (GH-134194) (#135192)
gh-134155: fix AttributeError in email._header_value_parser.get_address (GH-134194)

Append the defect to defects instead of to the parse tree.
(cherry picked from commit d9cad074d5)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-06-06 14:11:15 -04:00
Serhiy Storchaka
d864a9150b
[3.13] gh-135120: Add test.support.subTests() (GH-135121) (GH-135210)
(cherry picked from commit 6ef06fad84)
2025-06-06 13:16:50 +00:00
Serhiy Storchaka
e2a9a3fa98
[3.13] gh-131884: Fix incorrect formatting in json.dumps() when using indent and skipkeys=True (GH-132200) (GH-135061)
(cherry picked from commit ec12559eba)

Co-authored-by: Roei Ben Artzi <155478676+roeibenartzi@users.noreply.github.com>
2025-06-05 14:38:11 +00:00
Miss Islington (bot)
5a69d4fe00
[3.13] gh-135124: Change stdout errors in regrtest worker process (GH-135138) (#135169)
gh-135124: Change stdout errors in regrtest worker process (GH-135138)

Set sys.stdout encoder error handler to backslashreplace in regrtest
workers to avoid UnicodeEncodeError when printing a traceback
or any other non-encodable character.

Move the code from the Regrtest class to setup_process().

Call setup_process() earlier, before displaying regrtest headers.
(cherry picked from commit 3d396ab759)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-06-05 10:11:26 +00:00
Miss Islington (bot)
ae2e7958f2
[3.13] gh-126483: disable warnings filters mutation in concurrent test (GH-132694) (GH-135132)
The `test_ssl_in_multiple_threads` test failed because `test_check_hostname_idn()`
modified the global warnings filters via `warnings_helper.check_no_resource_warning()`.
Disable the warnings check in the multi-threaded test because `warnings_helper` isn't
thread-safe in 3.13 or earlier.
(cherry picked from commit 40c8be0008)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>

* Fix for 3.13

---------

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-06-04 13:29:22 +00:00
Miss Islington (bot)
70c7aad306
[3.13] gh-135074: Fix exception messages in test.support module (GH-135076) (GH-135130)
(cherry picked from commit bc00ce941e)

Co-authored-by: Daniel Hollas <daniel.hollas@bristol.ac.uk>
2025-06-04 13:22:02 +00:00
T. Wouters
aa9eb5f757
[3.13] gh-135034: Normalize link targets in tarfile, add os.path.realpath(strict='allow_missing') (GH-135037) (GH-135064)
Addresses CVEs 2024-12718, 2025-4138, 2025-4330, and 2025-4517.
(cherry picked from commit 3612d8f517)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Signed-off-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Seth Michael Larson <seth@python.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-03 15:59:54 +02:00
Miss Islington (bot)
f67dede253
[3.13] gh-133454: Mark test_queue tests with many threads as bigmem (gh-134575) (GH-135047)
50 producer and 50 consumer threads need more than 5GB of memory.
(cherry picked from commit 7a79f52d83)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-02 20:49:32 +00:00
Serhiy Storchaka
3e1b8d6e67
[3.13] gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658) (GH-134965)
random.getrandbits() can now generate more that 2**31 bits.
random.randbytes() can now generate more that 256 MiB.
(cherry picked from commit 68784fed78)
2025-06-02 23:16:30 +03:00
Sam Gross
a9b8ffd9b9
[3.13] gh-134908: Protect textiowrapper_iternext with critical section (gh-134910) (gh-135040)
The `textiowrapper_iternext` function called `_textiowrapper_writeflush`, but did not
use a critical section, making it racy in free-threaded builds.
(cherry picked from commit 44fb7c361c)

Co-authored-by: Duane Griffin <duaneg@dghda.com>
2025-06-02 19:40:42 +00:00
Miss Islington (bot)
7ca17edd13
[3.13] gh-130999: Avoid exiting the new REPL when there are non-string candidates for suggestions (gh-131001) (gh-135020)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-06-02 16:58:29 +02:00
Bénédikt Tran
2c325e28c3
[3.13] gh-134696: align OpenSSL and HACL*-based hash functions constructors AC signatures (GH-134713) (#134962)
OpenSSL and HACL*-based hash functions constructors now support both `data` and `string` parameters.
Previously these constructor functions inconsistently supported sometimes `data` and sometimes `string`,
while the documentation expected `data` to be given in all cases.

(cherry picked from commit c6e63d9d35)
(cherry picked from commit 379d0bc956)
2025-06-01 10:27:02 +02:00
Miss Islington (bot)
379c4a2002
[3.13] gh-134954: Hard-cap max file descriptors in subprocess test fd_status (GH-134955) (#134981)
gh-134954: Hard-cap max file descriptors in subprocess test fd_status (GH-134955)

* Hard-cap max file descriptors in subprocess test fd_status

On some systems, `SC_OPEN_MAX` may return a very large value (i.e. 10**30), leading to the subprocess test timing out (or run forever).
Prevent this situation by applying a hard cap on how many file descriptors are checked.

* Fix typo in usage docstring

s/fd_stats/fd_status/
(cherry picked from commit f58873e4b2)

Co-authored-by: Itamar Oren <itamarost@gmail.com>
2025-05-31 14:51:48 +00:00
Serhiy Storchaka
681856c194
[3.13] gh-134718: Fix ast.dump() for empty non-default values (GH-134926) (GH-134936)
(cherry picked from commit cc344e8dd0)
2025-05-30 15:48:48 +00:00
Miss Islington (bot)
dcfb22935f
[3.13] gh-108885: Imporove tests for doctest (GH-134832) (GH-134856)
Test the error and failure report in more detail.
(cherry picked from commit f6324bc7ee)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-28 17:38:02 +00:00
Miss Islington (bot)
07d4b6313f
[3.13] gh-133711: Fix test_readline.test_nonascii() for UTF-8 Mode (GH-134841) (#134852)
gh-133711: Fix test_readline.test_nonascii() for UTF-8 Mode (GH-134841)

Skip the test if the Python UTF-8 Mode is enabled and the LC_CTYPE
encoding is not UTF-8.
(cherry picked from commit 4635115c3f)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-05-28 16:08:08 +00:00
Miss Islington (bot)
a0287bf574
[3.13] gh-128840: Fix parsing long IPv6 addresses with embedded IPv4 address (GH-134836) (#134846)
gh-128840: Fix parsing long IPv6 addresses with embedded IPv4 address (GH-134836)
(cherry picked from commit d83576bf48)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-28 15:46:40 +00:00
Miss Islington (bot)
5511533f59
[3.13] gh-133711: Fix test_regrtest for PYTHONUTF8=1 (GH-134839) (#134843)
gh-133711: Fix test_regrtest for PYTHONUTF8=1 (GH-134839)

Use "backslashreplace" error handler to decode stdout and stderr.
Example:

    vstinner@WIN C:\victor\python\main\build\test_python_worker_8360\x91>
    "C:\victor\python\main\PCbuild\amd64\python_d.exe"  -m test
    --fast-ci --slow-ci --testdir
    C:\Users\vstinner\AppData\Local\Temp\tmp0t59e8da
    test_regrtest_noop1 test_regrtest_noop2 test_regrtest_noop3
    test_regrtest_noop4

Notice the "\x91" byte at the end of the first line: it's the
non-ASCII U+00E6 character encoded to the OEM cp437 code page.
(cherry picked from commit 91618278e7)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-05-28 15:44:03 +00:00
Miss Islington (bot)
741040236e
[3.13] gh-134744: Fix fcntl error handling (GH-134748) (GH-134795) (#134798)
[3.14] gh-134744: Fix fcntl error handling (GH-134748) (GH-134795)

gh-134744: Fix fcntl error handling (GH-134748)

Fix also reference leak on buffer overflow.
(cherry picked from commit 8a6a6f39c8)


(cherry picked from commit 9300a596d3)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-05-28 12:54:53 +02:00
Mark Shannon
814ac0d587
[3.13] gh-128161: Remove redundant GET_ITER from list comprehension code (backport of GH-134778) (GH-134788) 2025-05-27 14:12:04 +01:00
Miss Islington (bot)
08e1ba8813
[3.13] gh-134152: Fix UnboundLocalError in email._header_value_parser _get_ptext_to_endchars (GH-134233) (#134677)
Co-authored-by: R. David Murray <rdmurray@bitdance.com>
2025-05-26 11:02:58 +03:00
Sergey B Kirpichev
e483dcf19e
[3.13] gh-132876: workaround broken ldexp() on Windows 10 (GH-133135) (#134685)
* gh-132876: workaround broken ldexp() on Windows 10

ldexp() fails to round subnormal results before Windows 11,
so hide their bug.
(cherry picked from commit cf8941c603)

Co-authored-by: Tim Peters <tim.peters@gmail.com>
2025-05-25 22:39:34 -05:00
Miss Islington (bot)
2e30341478
[3.13] gh-128840: Limit the number of parts in IPv6 address parsing (GH-128841) (#134611)
gh-128840: Limit the number of parts in IPv6 address parsing (GH-128841)

GH-128840: Limit the number of parts in IPv6 address parsing
Limit length of IP address string to 39

---------
(cherry picked from commit 47f1161d3a)

Co-authored-by: Seth Michael Larson <seth@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-05-23 20:33:40 -07:00
Miss Islington (bot)
e4c4ecccec
[3.13] gh-134381: Fix RuntimeError when starting not-yet started Thread after fork (gh-134514) (gh-134597)
(cherry picked from commit 9a2346df86)

Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
2025-05-23 19:45:51 +00:00
Serhiy Storchaka
0308612508
[3.13] gh-134578: Mark more slow tests (GH-134579) (GH-134592)
(cherry picked from commit 77eade39f9)
2025-05-23 17:31:05 +00:00
Miss Islington (bot)
ba9f533f93
[3.13] gh-71339: Use new assertion methods in the http tests (GH-129058) (GH-132500)
(cherry picked from commit 7076d076c2)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-22 09:40:26 +00:00
Miss Islington (bot)
6126b7cf88
[3.13] gh-71339: Use new assertion methods in the urllib tests (GH-129056) (GH-132499)
(cherry picked from commit f98b9b4cbb)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-22 09:40:19 +00:00
Miss Islington (bot)
34d3495f32
[3.13] gh-71339: Use new assertion methods in the email tests (GH-129055) (GH-132501)
(cherry picked from commit 522766aa23)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-22 09:40:04 +00:00
Miss Islington (bot)
044fe0b2e1
[3.13] gh-131357: Add some extra tests for empty bytes and bytearray (GH-134458) (#134490)
gh-131357: Add some extra tests for empty bytes and bytearray (GH-134458)
(cherry picked from commit 7309eb60c0)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
2025-05-22 07:28:44 +00:00
Miss Islington (bot)
e0822d8d1c
[3.13] gh-134062: Fix hash collisions in IPv4Network and IPv6Network (GH-134063) (#134477)
gh-134062: Fix hash collisions in IPv4Network and IPv6Network (GH-134063)
(cherry picked from commit f3fc0c16e0)


gh-134062: Fix hash collisions in IPv4Network and IPv6Network
gh-134062: Add hash collision regression test

Co-authored-by: Mike Salvatore <mike.s.salvatore@gmail.com>
2025-05-22 03:12:28 +00:00
Miss Islington (bot)
e1e8533a5d
[3.13] gh-133982: Run unclosed file test on all io implementations (gh-134165) (gh-134434)
Update `test_io` `_check_warn_on_dealloc` to use `self.` to dispatch to
different I/O implementations.

Update the `_pyio` implementation to match expected behavior, using the
same `_dealloc_warn` design as the C implementation uses to report the
topmost `__del__` object.

The FileIO one now matches all the others, so can use IOBase. There was
a missing check on closing (self._fd must be valid), add that check
(cherry picked from commit 5b0e827521)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
2025-05-21 17:28:29 +02:00
Miss Islington (bot)
046125e5b6
[3.13] gh-71253: Match _io exception in _pyio (gh-133985) (gh-134431)
Test was only testing _io, expanded to cover _pyio.

(cherry picked from commit 06eaf4055c)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-05-21 17:14:00 +02:00
Miss Islington (bot)
de6d199c1d
[3.13] gh-133982: Update test_bufio to use self.open (gh-133983) (gh-134429)
(cherry picked from commit 84d5f8d799)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
2025-05-21 17:13:24 +02:00
Miss Islington (bot)
f5de0632d0
[3.13] gh-132542: Only run test_native_id_after_fork if native_id is supported (GH-134408) (GH-134414)
(cherry picked from commit e6dde10a69)

Co-authored-by: Noam Cohen <noam@noam.me>
2025-05-21 11:34:49 +00:00