15040 Commits

Author SHA1 Message Date
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 e6c3039cb39e68ae9af9ddcaca341c5af8f9cf23)

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 2b8b4774d29a707330d463f226630185cbd3ceff)

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)
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 8e8786f8986353e20c1c4406c34409a6139fa073)

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
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 f49a07b531543dd8a42d90f5b1c89c0312fbf806)

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
Miss Islington (bot)
dd4a819a82
[3.14] gh-134160: Use PyModuleDef.m_free in the example module xxlimited (GH-135174) (GH-135213)
gh-134160: Use PyModuleDef.m_free in the example module xxlimited (GH-135174)
(cherry picked from commit 1adca08d658ee2d520f3193960eaf3ae2ead1cef)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
2025-06-06 17:08:45 +02:00
Miss Islington (bot)
5b39741a09
[3.14] gh-134938: Add set_pledged_input_size() to ZstdCompressor (GH-135010) (GH-135173)
(cherry picked from commit 4b44b3409ac026e7f13054a3daa18ab7ee14d85c)

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 ec12559ebafca01ded22c9013de64abe535c838d)

Co-authored-by: Roei Ben Artzi <155478676+roeibenartzi@users.noreply.github.com>
2025-06-05 14:38:09 +00:00
Miss Islington (bot)
afe244d694
[3.14] gh-135108: Fix utmp.h inclusion in posixmodule.c on NetBSD (GH-135109) (GH-135127)
(cherry picked from commit 5b3865418ceb1448bfbf15cddf52c900cd5882a3)

Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
2025-06-04 13:16:39 +00:00
Miss Islington (bot)
d8c2bfac1f
[3.14] gh-127081: use getlogin_r if available (gh-132751) (gh-135097)
The `getlogin` function is not thread-safe: replace with `getlogin_r` where
available.
(cherry picked from commit 1ffe913c2017b44804aca18befd45689df06c069)

Co-authored-by: Duane Griffin <duaneg@dghda.com>
2025-06-03 14:41:47 -04:00
Miss Islington (bot)
94306f73f0
[3.14] gh-132813: Improve error messages for incorrect types and values of csv.Dialog attributes (GH-133241) (GH-135050)
Make them similar to PyArg_Parse error messages, mention None as
a possible value, show a wrong type and the string length.
(cherry picked from commit df98a47a61a274eb7427c6201ddabec9ffd30b0a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-02 21:01:18 +00:00
Miss Islington (bot)
428b0ca114
[3.14] gh-134908: Protect textiowrapper_iternext with critical section (gh-134910) (gh-135039)
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 44fb7c361cb24dcf9989a7a1cfee4f6aad5c81aa)

Co-authored-by: Duane Griffin <duaneg@dghda.com>
2025-06-02 19:16:54 +00:00
Miss Islington (bot)
035c4d6238
[3.14] gh-132983: Minor fixes and clean up for the _zstd module (GH-134930) (GH-134998)
(cherry picked from commit b5952371668089299bc8472c1adb9f8a0e69b4a2)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-06-01 08:46:51 +00:00
Bénédikt Tran
777fd4979c
[3.14] gh-134696: align OpenSSL and HACL*-based hash functions constructors AC signatures (GH-134713) (#134961)
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 c6e63d9d351f6d952000ec3bf84b3a7607989f92)
(cherry picked from commit 379d0bc95646dfe923e7ea05fb7f1befbd85572d)
2025-06-01 10:26:56 +02:00
Miss Islington (bot)
7c1dfd9c98
[3.14] gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658) (#134964)
gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658)

random.getrandbits() can now generate more that 2**31 bits.
random.randbytes() can now generate more that 256 MiB.
(cherry picked from commit 68784fed78aa297f0de0d038742495709185bef5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-31 20:02:38 -07:00
Miss Islington (bot)
a8708f7320
[3.14] gh-133891: Add missing error check to SET_COUNT macro in _testinternalcapi.c (GH-133892) (#134988)
gh-133891: Add missing error check to `SET_COUNT` macro in `_testinternalcapi.c` (GH-133892)
(cherry picked from commit cebae977a63f32c3c03d14c040df3cea55b8f585)

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-05-31 21:57:52 +00:00
Miss Islington (bot)
d45d053267
[3.14] gh-132775: Expand the Capability of Interpreter.call() (gh-134933)
It now supports most callables, full args, and return values.

(cherry picked from commit 52deabe, AKA gh-133484)

Co-authored-by: Eric Snow ericsnowcurrently@gmail.com
2025-05-30 18:28:35 +00:00
Miss Islington (bot)
f28f9304bf
[3.14] gh-134885: zstd: Use Py_XSETREF (GH-134886) (GH-134922)
(cherry picked from commit 45c6c48afc13f9897010e32171a3e02d0624258c)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2025-05-30 12:50:42 +02:00
Miss Islington (bot)
e0e8f28f27
[3.14] gh-134768: Fix definition of mt_continue_should_break() (GH-134769) (#134916)
gh-134768: Fix definition of `mt_continue_should_break()` (GH-134769)

In 121ed71f4e395948d313249b2ad33e1e21581f8a, mt_continue_should_break
was changed to be guarded by `Py_DEBUG`, but it's used in `compress_mt_continue_lock_held`
with just `assert`, so it needs to be available when `NDEBUG` is undefined
too.

`Py_DEBUG` implies `NDEBUG` is undefined, so we can check just that.
(cherry picked from commit 2f2bee21118adce653ee5bc4eb31d30327465966)


Fixes: 121ed71f4e395948d313249b2ad33e1e21581f8a

Co-authored-by: Sam James <sam@gentoo.org>
2025-05-30 05:08:43 +00:00
Miss Islington (bot)
4670dddbf6
[3.14] GH-133912: Fix PyObject_GenericSetDict to handle inline values (GH-134725) (#134859) 2025-05-29 11:19:58 -07:00
Miss Islington (bot)
4841201666
[3.14] gh-132983: Convert dict_content to take Py_buffer in `ZstdDict()` (GH-133924) (#134723)
gh-132983: Convert dict_content to take Py_buffer in ``ZstdDict()`` (GH-133924)
(cherry picked from commit f2ce4bbdfdfa2b658fbeef66f414be2ecf7981dd)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-28 17:25:35 +01:00
Miss Islington (bot)
117bb29f6b
[3.14] gh-132983: Split `_zstd_set_c_parameters` (GH-133921) (#134838)
gh-132983: Split ``_zstd_set_c_parameters`` (GH-133921)
(cherry picked from commit 11f7a939debd7731d1cb79ed84a473fa87c279c8)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-05-28 17:25:06 +01:00
Miss Islington (bot)
58549cfd49
[3.14] gh-134210: handle signals in _curses.window.getch (GH-134326) (#134783)
gh-134210: handle signals in `_curses.window.getch` (GH-134326)
(cherry picked from commit 51762b6cadb8f316dd783716bc5c168c2e2d07f0)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-05-27 09:16:50 +00:00
Eric Snow
e86efabaee
[3.14] gh-132775: Unrevert "Use _PyCode GetScriptXIData()" (gh-134736)
This reverts commit 7476f90af2cf9207c792c0dc3ee9a5ca7b4fabfa, AKA gh-134600.

This effectively unreverts commit bbf8048c0f9c (gh-134515).
2025-05-26 19:41:14 +00:00
Miss Islington (bot)
8c699015c5
[3.14] gh-134637: Fix performance regression in calling ctypes function pointer in free threading. (GH-134702) (#134742)
gh-134637: Fix performance regression in calling `ctypes` function pointer in `free threading`. (GH-134702)

Fix performance regression in calling `ctypes` function pointer in `free threading`.
(cherry picked from commit 3c0525126ef95efe2f578e93db09f3282e3ca08f)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-05-26 18:51:13 +00:00
Miss Islington (bot)
2a089244f0
[3.14] gh-134693: Fix [-Wmaybe-uninitialized] warning in _remote_debugging_module.c (GH-134694) (#134726)
gh-134693: Fix `[-Wmaybe-uninitialized]` warning in `_remote_debugging_module.c` (GH-134694)
(cherry picked from commit 806107d7a2fa9baa76d4025f46fab2c8725963f4)

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-05-26 15:32:52 +00:00
Miss Islington (bot)
aded785b8c
[3.14] gh-91048: Add better error messages for remote debugging for CI builds (GH-134682) (#134719) 2025-05-26 15:04:36 +00:00
Bénédikt Tran
072f50fc12
[3.14] gh-132710: only use stable _uuid.generate_time_safe() to deduce MAC address (GH-132901) (#134697)
(cherry picked from commit 3bffada46728e51f84c41ecbb0d3722595693e63)
2025-05-26 10:45:36 +00:00
Bénédikt Tran
ed52549c37
[3.14] gh-134208: remove dead AC directives for _curses.window.{chgat,getstr,instr} (GH-134325) (#134701)
(cherry picked from commit 29e81159644cf78d958e30aaef208e22a04a8b25)
2025-05-26 10:09:02 +00:00
Miss Islington (bot)
16187b58bf
[3.14] gh-132876: workaround broken ldexp() on Windows 10 (GH-133135) (#134684)
gh-132876: workaround broken ldexp() on Windows 10 (GH-133135)

* 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 cf8941c60356acdd00055e5583a2d64761c34af4)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Tim Peters <tim.peters@gmail.com>
2025-05-25 22:23:45 -05:00
Pablo Galindo Salgado
1822f33b1a
[3.14] gh-91048: Refactor and optimize remote debugging module (#134652) (#134673)
gh-91048: Refactor and optimize remote debugging module (#134652)

Completely refactor Modules/_remote_debugging_module.c with improved
code organization, replacing scattered reference counting and error
handling with centralized goto error paths. This cleanup improves
maintainability and reduces code duplication throughout the module while
preserving the same external API.

Implement memory page caching optimization in Python/remote_debug.h to
avoid repeated reads of the same memory regions during debugging
operations. The cache stores previously read memory pages and reuses
them for subsequent reads, significantly reducing system calls and
improving performance.

Add code object caching mechanism with a new code_object_generation
field in the interpreter state that tracks when code object caches need
invalidation. This allows efficient reuse of parsed code object metadata
and eliminates redundant processing of the same code objects across
debugging sessions.

Optimize memory operations by replacing multiple individual structure
copies with single bulk reads for the same data structures. This reduces
the number of memory operations and system calls required to gather
debugging information from the target process.

Update Makefile.pre.in to include Python/remote_debug.h in the headers
list, ensuring that changes to the remote debugging header force proper
recompilation of dependent modules and maintain build consistency across
the codebase.

Also, make the module compatible with the free threading build as an extra :)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>

(cherry picked from commit 42b25ad4d3d6bcdc28ddfe07d2bf8831378bb0d1)
2025-05-25 22:10:20 +00:00
Miss Islington (bot)
38a38243b7
[3.14] gh-132983: Make _zstd C code PEP 7 compliant (GH-134605) (#134609)
gh-132983: Make _zstd C code PEP 7 compliant (GH-134605)

Make _zstd C code PEP 7 compliant
(cherry picked from commit 973b8f69d31b4d86c37e0b7194a209f4f2efff06)

Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-05-24 02:28:40 +00:00
Miss Islington (bot)
f301af627e
[3.14] gh-132983: Slightly tweak error messages for _zstd compressor/decompressor options dict (GH-134601) (#134602)
gh-132983: Slightly tweak error messages for _zstd compressor/decompressor options dict (GH-134601)

Slightly tweak error messages for options dict
(cherry picked from commit f478331f98930d94f7efc741f3bed4b693d5cec1)

Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-05-23 22:18:08 +00:00
Eric Snow
7476f90af2
[3.14] gh-134557: Revert "[3.14] gh-132775: Use _PyCode GetScriptXIData()" (gh-134600)
This reverts commit bbf8048c0f9c, AKA gh-134515.

We are reverting due to refleaks on free-threaded builds.
2025-05-23 20:11:38 +00:00
Miss Islington (bot)
09a34f1f65
[3.14] gh-134381: Fix RuntimeError when starting not-yet started Thread after fork (gh-134514) (gh-134596)
(cherry picked from commit 9a2346df861f26d5f8d054ad2f9c37134dee3822)

Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
2025-05-23 19:49:13 +00:00
Miss Islington (bot)
81675941fb
[3.14] gh-133885: Use locks instead of critical sections for _zstd (gh-134289) (gh-134560)
Move from using critical sections to locks for the (de)compression methods.
Since the methods allow other threads to run, we should use a lock rather
than a critical section.
(cherry picked from commit 8dbc11971974a725dc8a11c0dc65d8f6fcb4d902)

Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-05-23 10:00:38 +00:00
Miss Islington (bot)
7480e50217
[3.14] gh-132775: Fix Recently Introduced Warnings (gh-134532)
(cherry picked from commit ac06b534eed, AKA gh-134530)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-05-22 17:49:05 +00:00
Miss Islington (bot)
04e2dd6513
[3.14] gh-132775: Make _PyXI_session Opaque (gh-134522)
This is mostly a refactor to clean things up a bit, most notably the "XI namespace" code.

Making the session opaque requires adding the following internal-only functions:

* _PyXI_NewSession()
* _PyXI_FreeSession()
* _PyXI_GetMainNamespace()

(cherry picked from commit 4a4ac3ab4d, gh-134452)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-05-22 17:12:52 +00:00
Miss Islington (bot)
068d570be8
[3.14] gh-134322: Fix repr(threading.RLock) (GH-134389) (#134528)
gh-134322: Fix `repr(threading.RLock)` (GH-134389)

Fix the `__repr__` value of `threading.RLock` from `_thread` module, when just created.
(cherry picked from commit fade146cfb1616ad7b3b918bedb86756dedf79e6)

Co-authored-by: Duprat <yduprat@gmail.com>
2025-05-22 17:12:21 +00:00
Miss Islington (bot)
bbf8048c0f
[3.14] gh-132775: Use _PyCode GetScriptXIData() (gh-134515)
(cherry picked from commit 09e72cf091d, AKA gh-134511)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-05-22 15:07:11 +00:00
Miss Islington (bot)
c31b25c705
[3.14] gh-133740: Fix locale.nl_langinfo(ALT_DIGITS) (GH-134468) (#134512)
gh-133740: Fix locale.nl_langinfo(ALT_DIGITS) (GH-134468)

Set the LC_CTYPE locale to the LC_TIME locale even if
nl_langinfo(ALT_DIGITS) result is ASCII. The result is a list
separated by NUL characters and the code only checks the first list
item which can be ASCII whereas following items are non-ASCII.

Fix test__locale for the uk_UA locale on RHEL 7.
(cherry picked from commit 899c7dc283cb899fdfd79fb479b38352f48e454a)

Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-22 14:31:26 +00:00
Miss Islington (bot)
ced49a196f
[3.14] gh-134323: Fix the new threading.RLock.locked method (GH-134368) (#134510)
gh-134323: Fix the new `threading.RLock.locked` method (GH-134368)
(cherry picked from commit 3effede97cc13fc0c5ab5dcde26cc319f388e84c)

Co-authored-by: Duprat <yduprat@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-05-22 14:14:53 +00:00
Miss Islington (bot)
85c8c0a003
[3.14] gh-132775: Use _PyObject_GetXIData (With Fallback) (gh-134507)
This change includes some semi-related refactoring of queues and channels.

(cherry picked from commit d0eedfa10e, gh-134440)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-05-22 07:21:05 -06:00
Miss Islington (bot)
998991513b
[3.14] gh-127960 Fix the REPL to set the correct namespace by setting the correct __main__ module (gh-134275) (gh-134473)
The `__main__` module imported in the `_pyrepl` module points to the `_pyrepl` module itself when the interpreter was launched without `-m` option and didn't execute a module,
while it's an unexpected behavior that `__main__` can be `_pyrepl` and relative imports such as `from . import *` works based on the `_pyrepl` module.
(cherry picked from commit b1b8962443e7d418601658a4b05347a5a9161910)

Co-authored-by: Yuichiro Tachibana (Tsuchiya) <t.yic.yt@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-05-22 03:33:35 +02:00
Miss Islington (bot)
93ab55bd70
[3.14] gh-132775: Use _PyFunction_VerifyStateless() and _PyCode_VerifyStateless() (gh-134465)
(cherry picked from commit a66bae8bb, AKA gh-134439)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-05-21 20:43:29 +00:00
Miss Islington (bot)
11d77d2112
[3.14] gh-132983: Fix refleak in zstd dictionary functions (gh-134463)
(cherry picked from commit fb68776591485, AKA gh-134459)

Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-05-21 19:35:31 +00:00
Miss Islington (bot)
cdc92cd9fc
[3.14] gh-132983: Refactor shared code in train_dict and finalize_dict (GH-134432) (#134442)
gh-132983: Refactor shared code in train_dict and finalize_dict (GH-134432)

Refactor shared code in train_dict and finalize_dict
(cherry picked from commit c64a21454b3c139af9e88941a286885fc4828a7e)

Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-05-21 16:19:25 +00:00
Miss Islington (bot)
2ffc10bd39
[3.14] gh-132775: Support Fallbacks in _PyObject_GetXIData() (gh-134418)
It now supports a "full" fallback to _PyFunction_GetXIData() and then `_PyPickle_GetXIData()`.
There's also room for other fallback modes if that later makes sense.

(cherry picked from commit 88f8102a8f, AKA gh-133482)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-05-21 14:47:56 +00:00
Miss Islington (bot)
e379a71811
[3.14] gh-91048: Fix error path result in _remote_debugging_module (GH-134347) (#134399) 2025-05-21 00:20:53 +00:00
Miss Islington (bot)
04829d4d87
[3.14] gh-134209: use heap-allocated memory in _curses.window.{instr,getstr} (GH-134283) (#134391)
gh-134209: use heap-allocated memory in `_curses.window.{instr,getstr}` (GH-134283)

* made curses buffer heap allocated instead of stack
* change docs to explicitly mention the max buffer size
* changing GetStr() function to behave similarly too
* Update Doc/library/curses.rst
* Update instr with proper return error handling
* Update Modules/_cursesmodule.c
* change to strlen and better memory safety
* change from const int to Py_ssize_t
* add mem allocation guard
* update versionchanged to mention it was an increase.
* explicitly use versionchanged 3.14 as that is its own branch now.

TESTED: `python -m test -u curses test_curses`

---------
(cherry picked from commit aadda87b3d3d99cb9e8c8791bb9715a3f0209195)

Co-authored-by: tigerding <43339228+zydtiger@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-05-20 14:01:45 -07:00