Commit graph

55244 commits

Author SHA1 Message Date
Miss Islington (bot)
3ae8a5bed3
[3.14] gh-135376: Fix and improve test_random (GH-135377) (GH-135680)
* Remove duplicated code. Tests for Random and SystemRandom now share
  the code.
* Move implementation agnostic tests that was only run for SystemRandom,
  so they are now run for Random too.
* Add tests for __index__() support.
* Add tests for randint().
(cherry picked from commit c55512311b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-18 15:51:47 +00:00
Miss Islington (bot)
d4daf4da7e
[3.14] gh-135646: Raise consistent NameError exceptions in ForwardRef.evaluate() (GH-135663) (#135673)
gh-135646: Raise consistent `NameError` exceptions in `ForwardRef.evaluate()` (GH-135663)
(cherry picked from commit 343719d98e)

Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
2025-06-18 13:26:58 +00:00
Miss Islington (bot)
9ac369cb73
[3.14] gh-135335: flush stdout/stderr in forkserver after preloading modules (GH-135338) (#135670)
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:42:18 +00:00
Miss Islington (bot)
562f6d1639
[3.14] gh-134632: Add iOS/Android test skip for C API check for headers. (GH-135656) (#135657)
iOS and Android don't ship headers in the testbed, so we can't test for their existence.
(cherry picked from commit 1c7efaf58a)

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
2025-06-18 06:48:03 +00:00
Miss Islington (bot)
1429eefbff
[3.14] gh-119180: Only fetch globals and locals if necessary in annotationlib.get_annotations() (GH-135644) (#135654)
gh-119180: Only fetch globals and locals if necessary in `annotationlib.get_annotations()` (GH-135644)
(cherry picked from commit 504ae606e1)

Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
2025-06-18 04:24:08 +00:00
Miss Islington (bot)
9f63a54aec
[3.14] gh-127146: Emscripten: Fix pathlib glob_dotdot test (GH-135624) (#135653)
The Emscripten path resolver uses the same mechanism for resolving `..`
at a file system root as for resolving symlinks. This is because
roots don't store their mountpoints. If the parent of a node is itself,
it is a root but it might be a mountpoint in some other file system.

If a path has enough `..`'s at the root, it will return ELOOP.
Enough turns out to be 49.
(cherry picked from commit e4ccd46bf7)

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2025-06-18 04:19:43 +00:00
Miss Islington (bot)
a61bd7af6e
[3.14] gh-127146: Emscripten: Fix test failure due to missing os.link (GH-135626) (#135652)
Check for existence of os.link, rather than assuming it exists.
(cherry picked from commit ce58afb400)

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2025-06-18 04:03:32 +00:00
Miss Islington (bot)
bf189d7ab5
[3.14] gh-127146: Emscripten: Skip test_url2pathname_resolve_host (GH-135634) (#135651)
Emscripten currently `gethostbyname_r()` returns an incorrect
IP address for `localhost`. Will be resolved by upstream PR:
https://github.com/emscripten-core/emscripten/pull/24593
(cherry picked from commit 2a49c54ab2)

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2025-06-18 03:23:31 +00:00
Miss Islington (bot)
77e2ac14c6
[3.14] gh-127146: Allow ignored keys to be missing in test_sysconfig (GH-135622) (#135650)
Fixes the test on Emscripten where userbase can be missing.
(cherry picked from commit 28c71ee4b2)

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2025-06-18 03:17:22 +00:00
Miss Islington (bot)
2c29ee835a
[3.14] gh-132775: Fix Interpreter.call() __main__ Visibility (gh-135638)
As noted in the new tests, there are a few situations we must carefully accommodate
for functions that get pickled during interp.call().  We do so by running the script
from the main interpreter's __main__ module in a hidden module in the other
interpreter.  That hidden module is used as the function __globals__.

(cherry picked from commit 269e19e0a7, AKA gh-135595)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-06-17 20:24:08 +00:00
Hugo van Kemenade
26d485d122 Python 3.14.0b3 2025-06-17 18:40:54 +03:00
Miss Islington (bot)
1bd034de9d
[3.14] gh-134632: Fix build-details.json to use INCLUDEPY path (GH-134633) (#135605)
gh-134632: Fix `build-details.json` to use `INCLUDEPY` path (GH-134633)

* gh-134632: Fix `build-details.json` to use `INCLUDEPY` path

Fix ``build-details.json`` generation to use ``INCLUDEPY``, in order to
reference the ``pythonX.Y`` subdirectory of the include directory, as
required in :pep:`739`, instead of the top-level include directory.

* test_build_details: Add tests for the c_api section

* test_build_details: Expect pkgconfig for CPython unconditionally
(cherry picked from commit 0d582def34)

Co-authored-by: Michał Górny <mgorny@gentoo.org>
2025-06-17 08:31:10 +00:00
Miss Islington (bot)
d2292c29f7
[3.14] gh-135489: Show verbose output for failing tests during PGO profiling step with --enable-optimizations (#135599)
(cherry picked from commit 5b3a826888)

Co-authored-by: PuQing <me@puqing.work>
2025-06-17 01:37:39 -04:00
Miss Islington (bot)
2b1c0a76dc
[3.14] gh-135443: Sometimes Fall Back to __main__.__dict__ For Globals (gh-135593)
For several builtin functions, we now fall back to __main__.__dict__ for the globals
when there is no current frame and _PyInterpreterState_IsRunningMain() returns
true.  This allows those functions to be run with Interpreter.call().

The affected builtins:

* exec()
* eval()
* globals()
* locals()
* vars()
* dir()

We take a similar approach with "stateless" functions, which don't use any
global variables.

(cherry picked from commit a450a0ddec, AKA gh-135491)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-06-16 23:59:30 +00:00
Miss Islington (bot)
964c29d281
[3.14] gh-116738: Make _heapq module thread-safe (GH-135036) (gh-135309)
Use critical sections to make heapq methods that update the heap thread-safe when the GIL is disabled.
(cherry picked from commit a58026a5e3)

Co-authored-by: Alper <alperyoney@fb.com>
Co-authored-by: mpage <mpage@meta.com>
2025-06-16 13:27:43 -04:00
Miss Islington (bot)
15f7bd4295
[3.14] gh-132617: Fix dict.update() mutation check (gh-134815) (gh-135581)
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)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-06-16 17:19:58 +00:00
Miss Islington (bot)
941011374a
[3.14] gh-119132: Remove "experimental" tag from the CPython free-threading. (gh-135550) (gh-135565)
---------
(cherry picked from commit f079979599)

Co-authored-by: Donghee Na <donghee.na@python.org>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: T. Wouters <thomas@python.org>
2025-06-16 14:58:14 +00:00
Mikhail Efimov
2ef78a85e4
[3.14] GH-135171: Revert async generator expressions behavior (#135352) 2025-06-16 17:45:42 +03:00
Miss Islington (bot)
43bf8b30f9
[3.14] gh-127319: Disable port reuse on HTTP, XMLRPC, and logging TCP servers (GH-135405) (GH-135538)
(cherry picked from commit 2bd3895fca)
2025-06-16 08:05:26 +01:00
Miss Islington (bot)
1c4f01a160
[3.14] gh-67022: Document bytes/str inconsistency in email.header.decode_header() and suggest email.headerregistry.HeaderRegistry as a sane alternative (GH-92900) (#135548)
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:16 -04:00
Miss Islington (bot)
f8f99b1cfc
[3.14] gh-135371: Fix asyncio introspection output to include internal coroutine chains (GH-135436) (#135509)
gh-135371: Fix asyncio introspection output to include internal coroutine chains (GH-135436)
(cherry picked from commit 028309fb47)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2025-06-15 18:38:56 +00:00
Miss Islington (bot)
6ae54553d4
[3.14] gh-65697: Improved error msg for configparser key validation (GH-135527) (#135541)
gh-65697: Improved error msg for configparser key validation (GH-135527)

* Improved error msg for configparser key validation and added note in 3.14 whatsnew

* Properly added change to configparser

* 📜🤖 Added by blurb_it.

---------
(cherry picked from commit 81237fbcf6)

Co-authored-by: Jacob Austin Lincoln <99031153+lincolnj1@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-06-15 16:38:15 +00:00
Miss Islington (bot)
79df5d1c54
[3.14] gh-135368: Fix mocks on dataclass specs with instance=True (GH-135421) (#135503)
gh-135368: Fix mocks on dataclass specs with `instance=True` (GH-135421)

* gh-135368: Fix mocks on dataclass specs with `instance=True`

* Extend dataclass mock_methods

---------
(cherry picked from commit c8319a3fea)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2025-06-14 09:11:31 +00:00
Miss Islington (bot)
7499bcd530
[3.14] gh-135496: Fix f string exclamation mark error typo (GH-135495) (#135499)
gh-135496: Fix f string exclamation mark error typo (GH-135495)
(cherry picked from commit c2bb3f9843)

Co-authored-by: GiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com>
2025-06-14 05:05:55 +00:00
Miss Islington (bot)
f77a911c52
[3.14] gh-135437: Account For Duplicate Names in _PyCode_SetUnboundVarCounts() (gh-135493)
(cherry picked from commit 56eabea, AKA gh-135438)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-06-13 23:14:00 +00:00
Miss Islington (bot)
d851f8e258
[3.14] gh-135462: Fix quadratic complexity in processing special input in HTMLParser (GH-135464) (GH-135481)
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:23:48 +00:00
Miss Islington (bot)
6754a507c5
[3.14] gh-132969: Fix error/hang when shutdown(wait=False) and task exited abnormally (GH-133222) (GH-135344)
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-13 15:49:54 +02:00
Miss Islington (bot)
b3efd3d7d3
[3.14] Revert "gh-135410: use a critical section around StringIO.__next__ (GH-135412)" (GH-135439) (gh-135449)
Revert "gh-135410: use a critical section around `StringIO.__next__` (GH-135412)" (GH-135439)

This reverts commit e6c3039cb3.
(cherry picked from commit 73431356d3)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-06-12 22:58:58 +00:00
Miss Islington (bot)
f885c7d9b9
[3.14] gh-135429: Fix the argument mismatch in lsprof throw event (GH-135442) (#135446)
gh-135429: Fix the argument mismatch in lsprof throw event (GH-135442)
(cherry picked from commit b03309fe5f)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2025-06-12 22:13:36 +00:00
Eric Snow
04273adae0
[3.14] gh-134939: Add the concurrent.interpreters Module (gh-135414)
PEP-734 has been accepted (for 3.14).

(FTR, I'm opposed to putting this under the concurrent package, but
doing so is the SC condition under which the module can land in 3.14.)

(cherry picked from commit 62143736b, AKA gh-133958)
2025-06-12 08:19:26 -06:00
Miss Islington (bot)
8cb7d9a810
[3.14] gh-135410: use a critical section around StringIO.__next__ (GH-135412) (#135425)
gh-135410: use a critical section around `StringIO.__next__` (GH-135412)
(cherry picked from commit e6c3039cb3)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-06-12 11:36:44 +00:00
Miss Islington (bot)
0e969fe843
[3.14] gh-135321: Always raise a correct exception for BINSTRING argument > 0x7fffffff in pickle (GH-135322) (GH-135382)
(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:01:15 +03:00
Miss Islington (bot)
30494cc72c
[3.14] gh-133967: Do not normalize locale name 'C.UTF-8' to 'en_US.UTF-8' (GH-135347) (GH-135349)
(cherry picked from commit 0f866cbfef)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-11 12:43:20 +03:00
Miss Islington (bot)
9f6c3769e3
[3.14] gh-135326: Test support of __index__ in random.getrandbits() (GH-135356) (#135373)
gh-135326: Test support of __index__ in random.getrandbits() (GH-135356)
(cherry picked from commit 5ae669fc4e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-11 02:17:06 +00:00
Miss Islington (bot)
f303532857
[3.14] gh-91048: Reorder result tuple of parse_code_object (GH-134898) (#134956)
* gh-91048:  Reorder result tuple of parse_code_object (GH-134898)

Reorder result tuple of parse_code_object

The standard followed by APIs like pstat.Stats is to take a file, line,
function triplet. The parse_code_object function (and callers exposing
this in Python like RemoteUnwinder.get_stack_trace) return function,
file, line triplets which requires the caller to reorder these when
using it in classes like pstat.Stats.
(cherry picked from commit 8e8786f898)

Co-authored-by: László Kiss Kollár <kiss.kollar.laszlo@gmail.com>

* Reorder asyncio

---------

Co-authored-by: László Kiss Kollár <kiss.kollar.laszlo@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2025-06-11 01:33:46 +00:00
Miss Islington (bot)
77c4b5d413
[3.14] gh-130077: Properly match full soft keywords in the parser (GH-135317) (#135348)
gh-130077: Properly match full soft keywords in the parser (GH-135317)
(cherry picked from commit ff2b5f40c2)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2025-06-11 02:01:37 +01:00
Miss Islington (bot)
88d8a2e9f0
[3.14] Docs: fix docstring of email.message.Message.add_header (GH-134355) (#135339)
Docs: fix docstring of `email.message.Message.add_header` (GH-134355)
(cherry picked from commit c23eec2960)

Co-authored-by: Alexander Shadchin <shadchin@yandex-team.com>
2025-06-10 11:00:25 +00:00
Victor Stinner
3d69d18322
[3.14] gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973) (#134974)
gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973)

Replace most PyUnicodeWriter_WriteUTF8() calls with
PyUnicodeWriter_WriteASCII().

(cherry picked from commit f49a07b531)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-09 14:37:26 +02:00
Mark Shannon
a5274cd215
[3.14] GH-135171: Fix generator expressions one last time (hopefully) (GH-135225)
* Add NULL check to FOR_ITER

* Move GET_ITER back to genexpr creation
2025-06-09 11:04:23 +01:00
Miss Islington (bot)
00f824dc5a
[3.14] gh-135276: Refresh zipfile.Path from zipp 3.23 (GH-135277) (#135278)
* 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 20:12:25 +00:00
Miss Islington (bot)
949248d6db
[3.14] gh-135244: generate UUID random Node ID with a CSPRNG as per RFC 9562, §6.10.3 (GH-135226) (#135255)
gh-135244: generate UUID random Node ID with a CSPRNG as per RFC 9562, §6.10.3 (GH-135226)

This aligns with the recommendations of RFC 9562, Section 6.10, paragraph 3 [1].

[1]: https://www.rfc-editor.org/rfc/rfc9562.html#section-6.10-3.

---------
(cherry picked from commit 1cb7163872)

Co-authored-by: LamentXU <108666168+LamentXU123@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-06-08 12:13:04 +00:00
Miss Islington (bot)
85efa77e35
[3.14] gh-134151 Fix TypeError in email.utils.decode_params when sorting RFC 2231 continuations (GH-134687) (#135247)
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:39 +00:00
Miss Islington (bot)
3faf00e003
[3.14] gh-134155: fix AttributeError in email._header_value_parser.get_address (GH-134194) (#135191)
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:13:30 -04:00
Serhiy Storchaka
5b38af57e0
[3.14] gh-135120: Add test.support.subTests() (GH-135121) (GH-135208)
(cherry picked from commit 6ef06fad84)
2025-06-06 13:03:28 +00:00
Miss Islington (bot)
4e2e02eec9
[3.14] gh-134993: Add os.lstat() to os.supports_dir_fd (GH-135188) (#135205)
gh-134993: Add os.lstat() to os.supports_dir_fd (GH-135188)
(cherry picked from commit e004cf8fd5)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-06-06 12:38:59 +00:00
mpage
be2f32e60f
[3.14] gh-134889: Fix handling of a few opcodes when optimizing LOAD_FAST (#134958) (#135187)
We were incorrectly handling a few opcodes that leave their operands on the stack. Treat all of these conservatively; assume that they always leave operands on the stack.

(cherry picked from commit 6b77af257c)
2025-06-05 13:06:51 -07:00
Miss Islington (bot)
945af60f04
[3.14] gh-135166: Fix exception type expected by test.test_zstd (GH-135167)
gh-135166: Fix exception type expected by test.test_zstd (GH-135167)
(cherry picked from commit 1b55e12766)

Co-authored-by: Weipeng Hong <hongweichen8888@sina.com>
2025-06-05 18:41:51 +01:00
Miss Islington (bot)
5b39741a09
[3.14] gh-134938: Add set_pledged_input_size() to ZstdCompressor (GH-135010) (GH-135173)
(cherry picked from commit 4b44b3409a)

Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-06-05 14:51:11 +00:00
Miss Islington (bot)
97822b8199
[3.14] gh-131884: Fix incorrect formatting in json.dumps() when using indent and skipkeys=True (GH-132200) (GH-135060)
(cherry picked from commit ec12559eba)

Co-authored-by: Roei Ben Artzi <155478676+roeibenartzi@users.noreply.github.com>
2025-06-05 14:38:09 +00:00
Miss Islington (bot)
285c69ea38
[3.14] gh-135124: Change stdout errors in regrtest worker process (GH-135138) (#135168)
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 09:42:38 +00:00