Commit Graph
9968 Commits
Author SHA1 Message Date
Miss Islington (bot)andノウラ | Flare 373bc1abdf [3.14] gh-157549: Use sysconf() for the page size in remote_debug.h (GH-157800) (#157814)
gh-157549: Use sysconf() for the page size in remote_debug.h (GH-157800)

getpagesize() is not an ISO C or POSIX function. Darwin hides the prototype under -std=c11, so the _remote_debugging build fails with -Werror=implicit-function-declaration. That is the failure in the reported x86_64-apple-darwin → arm64-apple-darwin cross build.

Call sysconf(_SC_PAGESIZE) instead, which is already how resource.getpagesize() works. Fall back to 4096 if sysconf() fails.

--without-remote-debug is unchanged. That flag only disables the target-side attach protocol (Py_REMOTE_DEBUG); it does not exclude the _remote_debugging client module.
(cherry picked from commit 9193375382)

Co-authored-by: ノウラ | Flare <nouraellm@gmail.com>
2026-09-19 16:45:19 +00:00
Pablo Galindo Salgado d3369c2f67 [3.14] gh-156114: Fix crash in perf trampoline with unencodable code names (GH-156300) (#157775) 2026-09-18 21:35:08 +00:00
Miss Islington (bot)andVictor Stinner c348765d48 [3.14] gh-128509: Use bytes singletons in marshal (GH-157398) (#157432)
gh-128509: Use bytes singletons in marshal (GH-157398)

Replace soft deprecated PyBytes_FromStringAndSize(NULL, n) with
PyBytes_FromStringAndSize(str, n) so marshal can get bytes singleton.
(cherry picked from commit 658612ae77)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-09-13 14:45:28 +00:00
Miss Islington (bot)andAbdul Mohammad 0ba71429fa [3.14] gh-155504: Set the interpreter before fallible thread state initialization (GH-155590) (#155885)
gh-155504: Set the interpreter before fallible thread state initialization (GH-155590)
(cherry picked from commit 94a75f74a1)

Co-authored-by: Abdul Mohammad <154353563+abdulm5@users.noreply.github.com>
2026-09-08 13:48:13 +05:30
Miss Islington (bot) dd36d014da [3.14] gh-156091: Fix crash compiling deeply nested inlined comprehensions (GH-156957) (#156993) 2026-09-05 16:27:05 +00:00
Miss Islington (bot)andStan Ulbrych 1546d44f6e [3.14] gh-156689: Fix out-of-bounds read in PyAst_CheckMode() for mode='func_type' (GH-156697) (#156704)
(cherry picked from commit d7f9c6400f)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-08-31 14:19:57 +01:00
Irit Katriel 3656c15ce8 [3.14]gh-156466: fix cleanup on error after Enter in codegen_enter_scope (#156467) (#156617)
gh-156466: fix cleanup on error after Enter in codegen_enter_scope (#156467)

(cherry picked from commit 41b3f0af26)
2026-08-30 14:14:31 +01:00
Irit Katriel e9eb34f390 [3.14] gh-156466: fix cleanup on error in codegen_leave_annotations_scope (#156522)
[3.14] gh-156466: fix cleanup on error in codegen_leave_annotations_scope
2026-08-30 14:13:40 +01:00
Miss Islington (bot)andSerhiy Storchaka d4ae98b0ec [3.14] gh-86427: Use the console code page for the stdio encoding on Windows (GH-155415) (GH-156603)
In the legacy Windows stdio mode PyConfig.stdio_encoding is now initialized
with the console output code page instead of the ANSI code page.

Only one encoding can be specified, so sys.stdin.encoding is still wrong if
the input code page differs from the output one.
(cherry picked from commit 0bb312a4ea)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-08-29 19:45:46 +00:00
Serhiy Storchaka 7755fce76f [3.14] gh-87587: Fix os.device_encoding() for any console on Windows (GH-155410) (GH-156596)
It was hard coded to map file descriptors 0, 1 and 2 to the console code
page, but a console can be opened as any file descriptor, and other
character devices, like NUL, are not consoles.

The file handle is now queried.  The UTF-8 code page is also now reported
as "utf-8" instead of "cp65001".

(cherry picked from commit b4aea41d1c)
2026-08-29 18:50:41 +00:00
Miss Islington (bot)andJelle Zijlstra bf85294394 [3.14] gh-156466: Fix additional compiler scope cleanup errors (GH-156547) (#156572)
gh-156466: Fix additional compiler scope cleanup errors (GH-156547)
(cherry picked from commit f4874f381c)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-08-29 12:42:26 +00:00
Miss Islington (bot)andIrit Katriel 4c949e3946 [3.14] gh-156525: fix a few error path scope management bugs in symtable (GH-156526) (#156533)
gh-156525: fix a few error path scope management bugs in symtable (GH-156526)
(cherry picked from commit 932822cbc9)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-08-28 19:56:34 -07:00
Miss Islington (bot)andIrit Katriel 28b944cc03 [3.14] gh-156466: fix cleanup on error in codegen_class_body (GH-156507) (#156536)
gh-156466: fix cleanup on error in codegen_class_body (GH-156507)
(cherry picked from commit 683ef4082d)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-08-28 21:35:29 +00:00
Miss Islington (bot) 56cc48239d [3.14] gh-156395: Report frozen objects on free-threaded GC build (GH-156396) (#156421)
gh-156395: Report frozen objects on free-threaded GC build (GH-156396)
2026-08-28 09:51:31 -07:00
Miss Islington (bot)andIrit Katriel 604ab79330 [3.14] gh-156466: fix cleanup on error in codegen_function_annotations (GH-156502) (#156509)
gh-156466: fix cleanup on error in codegen_function_annotations (GH-156502)
(cherry picked from commit 0e29768493)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-08-28 14:42:53 +00:00
Irit Katriel e93fe16a08 [3.14] gh-156466: fix cleanup on error in codegen_setup_annotations_scope (#156473) (#156499)
gh-156466: fix cleanup on error in codegen_setup_annotations_scope (#156473)

(cherry picked from commit 24e5a55ccb)
2026-08-28 10:42:36 +01:00
Kirill Podoprigora 7267c9b8f4 [3.14] gh-156126: Fix crash in -X importtime with unencodable module … (#156330)
[3.14] gh-156126: Fix crash in -X importtime with unencodable module names (GH-156137)

(cherry picked from commit 3a5aa68588)
2026-08-25 00:11:08 +03:00
stevensandStan Ulbrych 31e1476cc3 [3.14] gh-155952: Fix <unrepresentable> Argument Clinic defaults in several signatures (#156172)
(cherry picked from commit 5a7fd42138)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-08-21 13:23:30 +01:00
Miss Islington (bot)andNeil Schemenauer 8854fbcf6d [3.14] gh-155519: fix data-race for Context.ctx_vars (GH-155522) (#155892)
gh-155519: fix data-race for Context.ctx_vars (GH-155522)
(cherry picked from commit 9ee248c296)

Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
2026-08-20 15:21:09 +05:30
Serhiy Storchaka 90a1f02b7d [3.14] gh-113318: Fix @getter and @setter in Argument Clinic (GH-155778) (GH-156011)
(cherry picked from commit 915970ce9d)
2026-08-18 13:09:24 +00:00
Miss Islington (bot)andSerhiy Storchaka 483f589923 [3.14] gh-123011: Fix warn_explicit() with the globals of the __main__ module (GH-155318) (GH-155990)
The __main__ module executed as a script or a command has __spec__ set to
None, so warn_explicit(module_globals=globals()) emitted a spurious
DeprecationWarning.  It also raised ImportError when the loader was unable
to provide the source of the module: when the module was executed with -m
(the loader can only handle its own module name) or as a command (the
built-in importer has no source).
(cherry picked from commit f2eaf174b2)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-08-18 07:55:15 +00:00
Miss Islington (bot)andNeil Schemenauer 04350d9111 [3.14] gh-155515: Use GC tracking for HAMT iterators (GH-155517) (#155698)
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
2026-08-17 06:40:05 +03:00
Kirill PodoprigoraandIrit Katriel 12e77ac0f3 [3.14] gh-148817: Fold long lists/sets of constant elements into constant tu… (#155898)
gh-148817: Fold long lists/sets of constant elements into constant tuples/frozensets (#149016)

Fold long lists/sets of constant elements into constant tuples/frozensets.


(cherry picked from commit 084230eb2d)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2026-08-16 17:16:24 +03:00
Serhiy Storchaka 94e5346c84 [3.14] gh-155319: Fix the source line of a warning issued with module_globals (GH-155320) (GH-155825)
warn_explicit() computed the source line from the loader of the module
whose globals were passed as module_globals, but did not pass it to
WarningMessage.  It also raised IndexError if lineno was out of the range
of the module source.

(cherry picked from commit c92e2fd8f9)
2026-08-15 07:39:27 +00:00
Donghee Na c749534b06 [3.14] gh-129752: Don't update adaptive counters when TLBC=0 in free-threading. (gh-155497) (gh-155715)
(cherry picked from commit ee4fe00a8f)
2026-08-13 15:20:04 +00:00
Miss Islington (bot)andBatuhan Taskaya 14d128001d [3.14] gh-85260: Extend the AST Validator to validate all identifiers (GH-21069) (GH-155651)
(cherry picked from commit 47e21752b5)

Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
2026-08-13 05:58:06 +00:00
Miss Islington (bot)andstevens 87bacf1b49 [3.14] gh-151524: Make it clearer that _PyInstrumentation_DISABLE is immortal in the code (GH-151525) (GH-155349)
(cherry picked from commit 52bed26b79)

Co-authored-by: stevens <lipengyu@kylinos.cn>
2026-08-07 16:01:26 +00:00
Timofei Ivankov c21e7c45a9 [3.14] gh-154902: Type-check the SET_ADD operand (#155072) 2026-08-05 07:24:50 -07:00
Pablo Galindo Salgado 04735deeb2 [3.14] gh-149619: Harden _remote_debugging error paths (GH-150349) (#154844)
(cherry picked from commit a5be25d3bd)
2026-07-28 23:46:43 +01:00
Pablo Galindo Salgadoandivonastojanovic c533f180e0 [3.14] gh-149619: Fix _remote_debugging permissions error on Linux (GH-150012) (#154825)
When running profiling on Linux without sudo, attempts to read
process memory would fail with the misleading error 'Failed to find
the PyRuntime section in process <pid> on Linux platform'.

The actual issue is a permissions error because profiling was not
run with sudo. We were clearing the exception on Linux when trying
to read memory, instead, we should bubble up the permissions error
and show it properly.

(cherry picked from commit 0563890872)

Co-authored-by: ivonastojanovic <80911834+ivonastojanovic@users.noreply.github.com>
2026-07-28 22:53:39 +01:00
Miss Islington (bot)andCarlo Bramini 6065d74ca7 [3.14] gh-152903: Change PCWSTR to PWSTR in GetThreadDescription() typedef (GH-152904) (#152944)
gh-152903: Change PCWSTR to PWSTR in GetThreadDescription() typedef (GH-152904)

Fixes issue GH-152903
(cherry picked from commit ac1acb6d7d)

Co-authored-by: Carlo Bramini <carlo_bramini@users.sourceforge.net>
2026-07-26 18:27:03 +00:00
Serhiy StorchakaandClaude Opus 4.8 903265fd16 [3.14] gh-154283: Make threading.get_native_id() unique across processes on DragonFly (GH-154287) (GH-154297)
On DragonFly BSD lwp_gettid() is only unique within a process (the main
thread is always LWP 1), so combine it with the process id, like Solaris.
(cherry picked from commit 53597df11e)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 20:21:13 +00:00
1ba35ca180 [3.14] gh-151644: Fix data race in sys.setdlopenflags/getdlopenflags under free-threading (gh-151768) (gh-153789)
In free-threading builds, concurrent calls to sys.getdlopenflags() and
sys.setdlopenflags() race on interp->imports.dlopenflags.  Fix by
using FT_ATOMIC_LOAD_INT_RELAXED / FT_ATOMIC_STORE_INT_RELAXED in
_PyImport_GetDLOpenFlags and _PyImport_SetDLOpenFlags, consistent with
how analogous interpreter-state integer fields (lazy_imports_mode,
pystats_enabled) are protected.

Relaxed ordering is correct here: dlopenflags is a standalone config
integer with no ordering relationship to other memory.

(cherry picked from commit cde31ec135)

Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-17 13:13:30 -07:00
Victor Stinner 6374772d8c [3.14] gh-152132: Test Py_CompileString() in test_capi.test_run (#153470) (#153473)
gh-152132: Test Py_CompileString() in test_capi.test_run (#153470)

PyRun functions now raises ValueError if the start argument is
invalid.

Add Modules/_testlimitedcapi/run.c.

(cherry picked from commit d83d26724b)
2026-07-10 02:08:14 +00:00
Victor Stinner 62c34a62c2 [3.14] gh-152132: Fix Py_RunMain() to return an exit code (#153446) (#153455)
gh-152132: Fix Py_RunMain() to return an exit code (#153446)

* Fix Py_RunMain() to return an exit code, rather than calling
  Py_Exit(), when running a script, a command, or the REPL.
* _PyRun_SimpleFile() now logs errors to stderr, for example if setting
  __main__.__file__ fails.
* Add tests on Py_RunMain() exitcode.
* Rename functions:

  * _PyRun_SimpleStringFlagsWithName() => _PyRun_SimpleString()
  * _PyRun_SimpleFileObject() => _PyRun_SimpleFile()
  * _PyRun_AnyFileObject() => _PyRun_AnyFile()
  * _PyRun_InteractiveLoopObject() => _PyRun_InteractiveLoop()

* Change _PyRun_SimpleString(), _PyRun_SimpleFile(), _PyRun_AnyFile() and
  _PyRun_InteractiveLoop() return type to PyObject*.
* pymain_repl() now displays the error if PySys_Audit() or
  import _pyrepl failed.
* PyRun_SimpleFileExFlags() and PyRun_AnyFileExFlags() now log
  PyUnicode_DecodeFSDefault() error. So these functions can no longer
  return -1 with an exception set.

(cherry picked from commit fac72f1ee9)
2026-07-09 21:37:45 +02:00
Miss Islington (bot)andVictor Stinner 246d9ad255 [3.14] gh-152132: Test all PyRun functions in test_capi.test_run (GH-153352) (#153412)
gh-152132: Test all PyRun functions in test_capi.test_run (GH-153352)

PyRun_InteractiveOneObjectEx() now raises TypeError if the second
parameter type is not str.
(cherry picked from commit cd9994e283)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-07-09 11:18:23 +00:00
Victor Stinner 6241d0d46b [3.14] gh-153300: Set global configuration variables in PyConfig_Set() (#153301) (#153359)
gh-153300: Set global configuration variables in PyConfig_Set() (#153301)

PyConfig_Set() now also set global configuration variables. For
example, PyConfig_Set("inspect", value) now also sets Py_InspectFlag.

Use PyConfig_Set() in main.c to set the inspect flag. Python code can
now see the updated sys.flags.inspect value.

(cherry picked from commit 9fb713f1b8)
2026-07-08 20:20:45 +02:00
Miss Islington (bot)andsobolevn 3d802b5be9 [3.14] gh-153252: Fix error handling in _PyCompile_CodeGen (GH-153253) (#153282)
gh-153252: Fix error handling in `_PyCompile_CodeGen` (GH-153253)
(cherry picked from commit a74280e669)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-07-07 18:02:59 +00:00
97a45b0d00 [3.14] gh-153205: Set MemoryError in stackref array conversion (GH-153206) (#153273)
gh-153205: Set `MemoryError` in stackref array conversion (GH-153206)
(cherry picked from commit 08759ff101)

Co-authored-by: An Long <aisk@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
2026-07-07 16:32:27 +00:00
0903be826a [3.14] gh-152682: Fix NULL dereference on OOM in symtable_visit_type_param_bound_or_default (GH-152684) (#152696)
In `symtable_visit_type_param_bound_or_default()`, when a reserved name
(e.g. `__classdict__`) is used as a type parameter, `PyUnicode_FromFormat()`
is called to build the SyntaxError message. If the allocation fails and
returns NULL, the subsequent `PyErr_SetObject()` and `Py_DECREF()` calls
would dereference NULL, causing a segfault.

Fix by returning 0 immediately when `PyUnicode_FromFormat()` returns NULL.
This propagates the MemoryError set by `PyUnicode_FromFormat()`.

The bug was introduced in gh-128632 (commit 891c61c).
(cherry picked from commit 10ed03edf1)

Co-authored-by: Petr Vaganov <petrvaganoff@gmail.com>

* Remove test

---------

Co-authored-by: Petr Vaganov <petrvaganoff@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-07-06 17:35:58 +01:00
d80f581faa [3.14] gh-152849: Fix OverflowError message for out-of-range timestamps in the time module (GH-152850) (#153208)
(cherry picked from commit 2d7a74ece7)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-07-06 15:16:34 +00:00
Miss Islington (bot) 74c8d5ce0f [3.14] gh-151763: Fix OOM-0013 crash when the parser or compiler fails to allocate (GH-151968) (#152837) 2026-07-02 09:23:07 +01:00
Miss Islington (bot)andsobolevn fd4965de33 [3.14] gh-151126: Fix a possible crash during the startup with no memory under Py_STACKREF_DEBUG (GH-152478) (#152678)
gh-151126: Fix a possible crash during the startup with no memory under `Py_STACKREF_DEBUG` (GH-152478)
(cherry picked from commit ecdef17730)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-06-30 11:55:16 +00:00
Miss Islington (bot)andStan Ulbrych be68d9abca [3.14] gh-152375: Fix undefined behaviour in the INSTRUMENTED_JUMP macro (GH-152376) (#152567)
(cherry picked from commit cdec9acd63)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-29 09:40:05 +00:00
Łukasz Langa 9a9bceb953 [3.14] gh-151029: Fix sys.remote_exec() unable to find writable memory when libpython replaced on disk (GH-151032) (#152464) 2026-06-28 16:43:14 +02:00
Miss Islington (bot)andAmrutha 33b5aebfd4 [3.14] gh-151842: Fix crash upon OOM in _interpreters.capture_exception (GH-151843) (GH-152032)
(cherry picked from commit 5e0747db2f)

Co-authored-by: Amrutha <amruthamodela06@gmail.com>
2026-06-23 20:57:34 +00:00
Miss Islington (bot)anddev b471b4a6ba [3.14] gh-151773: Fix NULL dereference in PyContextVar_Set (GH-151836) (#152010)
gh-151773: Fix NULL dereference in `PyContextVar_Set` (GH-151836)
(cherry picked from commit d35b1719a5)

Co-authored-by: dev <b.chouksey27@gmail.com>
2026-06-23 14:41:31 +00:00
Miss Islington (bot)andDaniele Parmeggiani c1104577bf [3.14] gh-150902: Optimize PyCriticalSection2 to skip locking the same locks held by the current CS2 (gh-151555)
This mimics an optimization already present for the single-mutex critical section.
(cherry picked from commit c2ca7724af)

Co-authored-by: Daniele Parmeggiani <8658291+dpdani@users.noreply.github.com>
2026-06-19 09:51:55 -04:00
Victor Stinner c005251a2d [3.14] gh-151546: Fix stack limits on musl (#151548) (#151583) (#151591)
[3.15] gh-151546: Fix stack limits on musl (#151548) (#151583)

gh-151546: Fix stack limits on musl (#151548)

If the thread stack size is set by linker flags, pass the stack size
to Python/ceval.c via the new _Py_LINKER_THREAD_STACK_SIZE variable
to set Py_C_STACK_SIZE macro.

(cherry picked from commit 9a61d1c0c8)
(cherry picked from commit a5c5edddbc)
2026-06-17 09:41:24 +00:00
Victor StinnerandBénédikt Tran 60132db980 [3.14] gh-151218: Replace sys.flags in PyConfig_Set() (#151402) (#151553)
gh-151218: Replace sys.flags in PyConfig_Set() (#151402)

PyConfig_Set() and sys.set_int_max_str_digits() now replace
sys.flags (create a new object), instead of modifying sys.flags in-place.

Modifying sys.flags in-place can lead to data races when multiple
threads are reading or writing sys.flags in parallel.

Use _Py_atomic functions to get and set max_str_digits members.


(cherry picked from commit b16d23fc9f)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-06-16 18:55:35 +02:00