Commit Graph

32619 Commits

Author SHA1 Message Date
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
Miss Islington (bot) 4c22fa6570
[3.13] gh-131357: Add tests for zero-sized bytes objects in test_bytes.py (GH-134234) (#134379)
gh-131357: Add tests for zero-sized bytes objects in test_bytes.py (GH-134234)
(cherry picked from commit 306f9e04e5)

Co-authored-by: abstractedfox <coldcaption@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-05-20 18:56:32 +00:00
Noam Cohen aebbbaffe8
[3.13] gh-132542: Set native thread ID after fork (GH-132701) (GH-134361)
(cherry picked from commit 6b73502313)
2025-05-20 17:03:19 +00:00
Serhiy Storchaka 6279eb8c07
[3.13] gh-133767: Fix use-after-free in the unicode-escape decoder with an error handler (GH-129648) (GH-133944)
If the error handler is used, a new bytes object is created to set as
the object attribute of UnicodeDecodeError, and that bytes object then
replaces the original data. A pointer to the decoded data will became invalid
after destroying that temporary bytes object. So we need other way to return
the first invalid escape from _PyUnicode_DecodeUnicodeEscapeInternal().

_PyBytes_DecodeEscape() does not have such issue, because it does not
use the error handlers registry, but it should be changed for compatibility
with _PyUnicode_DecodeUnicodeEscapeInternal().
(cherry picked from commit 9f69a58623)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-20 14:46:57 +02:00
Miss Islington (bot) edf2de0178
[3.13] Clean up test_posixpath (GH-134315) (GH-134317)
* Ensure that created files and dirs are always removed after test.
  Now addCleanup() does not conflict with tearDown().
* Use os_helper.unlink() and os_helper.rmdir().
* Import TESTFN from os_helper.
(cherry picked from commit e29171bf8a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-20 08:15:29 +00:00
Miss Islington (bot) 783675e73f
[3.13] gh-133940: test_strftime incorrectly calculates expected week (GH-134281) (#134302)
gh-133940: test_strftime incorrectly calculates expected week (GH-134281)

Let the system determine the correct tm_wday and tm_isdst.
(cherry picked from commit e3dda8f818)

Co-authored-by: Gustaf <79180496+GGyll@users.noreply.github.com>
2025-05-20 01:17:22 +00:00
Miss Islington (bot) da506b2560
[3.13] gh-117596: Add more tests for os.path with invalid paths (GH-134189) (GH-134266)
(cherry picked from commit 871d269875)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-19 18:41:37 +00:00
Miss Islington (bot) 08c9ba5b72
[3.13] gh-134097: Print number of refs & blocks after each statement in new REPL (gh-134136) (gh-134221)
(cherry picked from commit c31547a591)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-05-19 16:13:25 +02:00
Serhiy Storchaka 06a8c0613e
[3.13] gh-133890: Handle UnicodeEncodeError in tarfile (GH-134147) (GH-134196)
UnicodeEncodeError is now handled the same way as OSError during
TarFile member extraction.
(cherry picked from commit 9983c7d441)
2025-05-19 10:37:36 +00:00
Miss Islington (bot) 821a87e7a6
[3.13] gh-133889: Only show the path of the URL in the SimpleHTTPRequestHandler page (GH-134135) (GH-134191)
The query and fragment are ambiguous and not used.
(cherry picked from commit 5cbc8c632e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-18 22:16:56 +03:00
Miss Islington (bot) 523024499e
[3.13] gh-134100: Fix use-after-free in `PyImport_ImportModuleLevelObject` (GH-134117) (#134172)
gh-134100: Fix use-after-free in `PyImport_ImportModuleLevelObject` (GH-134117)
(cherry picked from commit 4e9005d32f)

Co-authored-by: Nico-Posada <102486290+Nico-Posada@users.noreply.github.com>
2025-05-18 20:38:28 +05:30
Thomas Grainger fd6a602d04
[3.13] gh-133745: Fix asyncio task factory name/context kwarg breaks (#133948)
In 3.13.3 we accidentally broke the interface for custom task factory. Factory authors added workarounds.
This PR (for 3.13.4) unbreaks task factories that haven't made a workaround yet while also supporting those that have.

NOTE: The custom task factory API will change to what we accidentally released in 3.13.3.

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
2025-05-18 06:50:07 -07:00
Miss Islington (bot) bc0dc9d4ef
[3.13] gh-134098: Fix handling %-encoded trailing slash in SimpleHTTPRequestHandler (GH-134099) (GH-134124)
(cherry picked from commit 2f1ecb3bc4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-17 07:33:42 +00:00
Miss Islington (bot) 6dae082584
[3.13] gh-133889: Improve tests for SimpleHTTPRequestHandler (GH-134102) (GH-134122)
(cherry picked from commit fcaf009907)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-17 07:23:27 +00:00
Miss Islington (bot) f81f1bb2f9
[3.13] Test also error messages in test_limit_int. (GH-134018) (GH-134032)
(cherry picked from commit e123a1d09b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-15 07:45:00 +00:00
Miss Islington (bot) f474264b1e
[3.13] Improve tests for str to Fraction conversion (GH-134010) (GH-134017)
(cherry picked from commit 17d0fec702)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-14 17:42:23 +00:00
Sam Gross e1cc789531
gh-132869: Fix crash in `_PyObject_TryGetInstanceAttribute` (#133700)
This fixes a crash in `_PyObject_TryGetInstanceAttribute` due to the use
of `_PyDictKeys_StringLookup` on an unlocked dictionary that may be
concurrently modified.

The underlying bug was already fixed in 3.14 and the main branch.

(partially cherry picked from commit 1b15c89a17)
2025-05-14 12:47:34 +09:00
Brandt Bucher 50b45c4f45
[3.13] GH-133543: Maintain tracking for materialized instance dictionaries (GH-133617) 2025-05-12 13:00:01 -07:00
Serhiy Storchaka d9d8e9a00c
[3.13] gh-133677: Fix tests when running in non-UTF-8 locale (GH-133865) (GH-133939)
(cherry picked from commit 14305a83d3)
2025-05-12 17:02:19 +00:00
Victor Stinner 5ce47b96b0
[3.13] gh-133744: Fix multiprocessing interrupt test: add an event (#133746) (#133917)
gh-133744: Fix multiprocessing interrupt test: add an event (#133746)

Add an event to synchronize the parent process with the child
process: wait until the child process starts sleeping.

(cherry picked from commit c2989b7070)
2025-05-12 14:16:52 +00:00
Miss Islington (bot) 8e923f3659
[3.13] gh-91555: disable logger while handling log record (GH-131812) (GH-133898)
Co-authored-by: Duane Griffin <duaneg@dghda.com>
2025-05-12 07:29:06 +01:00
Victor Stinner 5cd56b249f
[3.13] gh-133441: Fix STORE_ATTR_WITH_HINT bytecode (#133446)
Deoptimize if the dict is a dict subclass.

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-05-11 23:10:04 +02:00
Inada Naoki f0a88e2ce5
gh-133703: dict: fix calculate_log2_keysize() (GH-133809)
(cherry picked from commit 92337f666e)
2025-05-11 15:14:11 +09:00