Commit Graph

10450 Commits

Author SHA1 Message Date
Miss Islington (bot) eaf4d73112 [3.15] gh-148825: Fix build error if specialization is disabled (GH-148826) (#152206)
gh-148825: Fix build error if specialization is disabled (GH-148826)
(cherry picked from commit 56ae0b8e4f)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2026-06-25 14:36:04 +00:00
Miss Islington (bot) 415e218ed5 [3.15] gh-151842: Fix crash upon OOM in _interpreters.capture_exception (GH-151843) (GH-152031)
(cherry picked from commit 5e0747db2f)

Co-authored-by: Amrutha <amruthamodela06@gmail.com>
2026-06-23 20:58:10 +00:00
Miss Islington (bot) 7b765a47b8 [3.15] gh-151773: Fix NULL dereference in PyContextVar_Set (GH-151836) (#152009)
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:46:05 +00:00
Miss Islington (bot) 80d7626c74 [3.15] gh-150902: Optimize PyCriticalSection2 to skip locking the same locks held by the current CS2 (gh-151554)
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:52:07 -04:00
Miss Islington (bot) 3135ab811d [3.15] gh-151436: Fix missing tstate->last_profiled_frame updates (GH-151437) (#151612)
gh-151436: Fix missing `tstate->last_profiled_frame` updates (GH-151437)
(cherry picked from commit a8d74c062f)

Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-06-19 10:24:53 +02:00
Miss Islington (bot) 8fe5897853 [3.15] gh-151510: Fix __lazy_import__ without frame (GH-151511) (#151610)
gh-151510: Fix __lazy_import__ without frame (GH-151511)
(cherry picked from commit eff805b7a7)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2026-06-17 18:40:33 +00:00
Victor Stinner a5c5edddbc [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)
2026-06-17 11:13:40 +02:00
Miss Islington (bot) ff6e973c3b [3.15] gh-151218: Replace sys.flags in PyConfig_Set() (GH-151402) (#151552)
gh-151218: Replace sys.flags in PyConfig_Set() (GH-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: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-06-16 16:48:56 +00:00
Miss Islington (bot) 255b3fff97 [3.15] gh-151223: fix tsan data races in load global specializations (GH-151393) (#151513)
gh-151223: fix tsan data races in load global specializations (GH-151393)
(cherry picked from commit e9d5280f6c)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2026-06-15 22:52:52 +05:30
Miss Islington (bot) 42e81e35a0 [3.15] gh-151112: Fix crash in compiler_mod() when entering the current compilation unit fails (GH-151234) (#151350)
(cherry picked from commit 937d89c4d9)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-11 15:22:31 +00:00
Miss Islington (bot) e3b94d8fa4 [3.15] gh-151112: Move an assert that may fail in cfg_builder_check (GH-151153) (#151313)
(cherry picked from commit 2d3381035d)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-11 09:46:04 +00:00
Miss Islington (bot) e8d914fd49 [3.15] gh-151278: Fix test_faulthandler on UBSan (GH-151279) (#151281)
gh-151278: Fix test_faulthandler on UBSan (GH-151279)

* Py_FatalError() no longer calls _PyFaulthandler_Fini() if it
  doesn't hold the GIL.
* Skip test_faulthandler tests raising signals if run with UBSan.
* Enable test_faulthandler in GitHub Action "Reusable Sanitizer".
(cherry picked from commit e60c42dc3f)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-06-10 20:07:07 +00:00
Victor Stinner 10f616cf39 [3.15] gh-151253: Dump the Python path configuration on _PyCodec_InitRegistry() failure (#151250) (#151269)
gh-151253: Dump the Python path configuration on _PyCodec_InitRegistry() failure (#151250)

If "import encodings" fails at Python startup, dump the Python path
configuration to help users debugging their configuration. The
encodings module is the first module imported during Python startup.

(cherry picked from commit 7b6e98911e)
2026-06-10 22:03:27 +02:00
Miss Islington (bot) 73e5d444ac [3.15] gh-150700: Fix class-scope inline comprehensions when nested scopes reference __class__ and friends (GH-150735) (#151211)
gh-150700: Fix class-scope inline comprehensions when nested scopes reference `__class__` and friends (GH-150735)

* Fix class-scope inline comprehensions when nested scopes reference `__class__` and friends

In `inline_comprehension()`, when `__class__` / `__classdict__` /
`__conditional_annotations__` appears as `FREE` in a comprehension's
symbol table because a nested scope captured it (e.g. nested lambdas),
this name is still discarded from `comp_free` unconditionally.

This prevents `drop_class_free()` from seeing it, so the appropriate
`ste_needs_(...)` flag is never set on the enclosing class.
That leads to `codegen_make_closure()` throwing `SystemError` when it
couldn't find `__class__` / `__classdict__` /
`__conditional_annotations__` in the class's cellvars.

From now on we just discard from `comp_free` when no child scope
(e.g. a lambda) still needs the name as `FREE`. When a child scope does
need it, keep it in `comp_free` so `drop_class_free()` can set the
appropriate flag and the class creates the implicit cell.

* Fix tests

* Fix typo

* Fix formatting

* Add test checking validity of `__class__` returned

* Prefer 'used' to 'deferred'
(cherry picked from commit ce916dc506)

Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
2026-06-09 16:33:04 -07:00
Miss Islington (bot) 50765f43f7 [3.15] gh-151112: Fix double free in assemble_init when out of memory (GH-151142) (#151205)
gh-151112: Fix double free in `assemble_init` when out of memory (GH-151142)
(cherry picked from commit 580499177c)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-09 20:16:42 +00:00
Miss Islington (bot) 8a2bf2a072 [3.15] gh-151126: Fix missing PyErr_NoMemory() in remove_unused_consts (GH-151127) (#151134)
gh-151126: Fix missing `PyErr_NoMemory()` in `remove_unused_consts` (GH-151127)
(cherry picked from commit 3186547c1e)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-06-09 10:33:02 +00:00
Pablo Galindo Salgado 83e26a43a7 [3.15] gh-149321: Remove lazy_imports=none startup mode (GH-149389) (#150129) 2026-06-08 22:55:57 +00:00
Miss Islington (bot) 5751633fac [3.15] gh-150633: Properly handle null characters in the name when importing frozen modules (GH-150634) (GH-151100)
(cherry picked from commit 54de5475cd)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
2026-06-08 18:58:11 +00:00
Miss Islington (bot) 06ffcde725 [3.15] gh-146527: Fix memory leak in _PyGC_Fini() (GH-150969) (#150970)
gh-146527: Fix memory leak in _PyGC_Fini() (GH-150969)

Free generation_stats allocated by _PyGC_Init().

Fix Python/gc.c: Python/gc_free_threading.c was already fixed.
(cherry picked from commit 0036565e81)

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-06-05 14:11:37 +00:00
Miss Islington (bot) f8cea98b4e [3.15] gh-149805: Fix SystemError when compiling __classdict__ class annotation (GH-149806)
(cherry picked from commit c52d2b16dd)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-03 09:39:22 +01:00
Miss Islington (bot) 53e7f2400a [3.15] gh-150723: Fix perf jitdump files on macOS (GH-150728) (#150832)
gh-150723: Fix perf jitdump files on macOS (GH-150728)

The perf jitdump format defines the thread id field of the JR_CODE_LOAD
record as a 32-bit value, but on macOS it was declared as a uint64_t
(since pthread_threadid_np() returns a uint64_t). Those extra 8 bytes
plus alignment padding shifted every following field, so parsers reading
the file by the spec misread code_size as the code address and failed to
resolve any Python frames.

Declare thread_id as uint32_t on all platforms and truncate the macOS
thread id when writing the record. The value is only informational.
Symbols are resolved by address, and not thread ids so truncation is
safe here.

* Use mach_absolute_time for macOS jitdump timestamps

On macOS the jitdump file is consumed by profilers such as samply, which
timestamp their samples using mach_absolute_time(). The jitdump events were
stamped with clock_gettime(CLOCK_MONOTONIC), a different clock domain that
keeps advancing while the system is asleep, so the JIT code mappings could be
off by days relative to the samples and no Python frame would resolve. Stamp
jitdump events with mach_absolute_time() on macOS so they share the sampler's
clock domain. Linux continues to use CLOCK_MONOTONIC to stay aligned with perf.

Exercise the -Xperf_jit (jitdump) backend through samply and assert that
Python frames resolve, exercising the binary jitdump path end to end.
Skipped when samply is not installed.
(cherry picked from commit 494f2e3c92)

Co-authored-by: Nazım Can Altınova <canaltinova@gmail.com>
2026-06-03 00:41:24 +00:00
Miss Islington (bot) 1c2daa08fb [3.15] gh-150319: Replace all documentation which says "See PEP 585" (GH-150325) (#150808)
gh-150319: Replace all documentation which says "See PEP 585" (GH-150325)

* Replace all documentation which says "See PEP 585"

The following classes in the stdlib get simple updates:

- array.array
- asyncio.Future
- asyncio.Task
- collections.defaultdict
- collections.deque
- contextvars.ContextVar
- contextvars.Token
- ctypes.Array
- os.DirEntry
- re.Match
- re.Pattern
- string.templatelib.Interpolation
- string.templatelib.Template
- types.MappingProxyType
- queue.SimpleQueue
- weakref.ref

The following classes are documented publicly as functions, and are
therefore updated internally (`__class_getitem__.__doc__`) but not in the
public docs:

- functools.partial
- itertools.chain

The following builtin types have updates to `__class_getitem__.__doc__`
but not to any documentation pages:

- BaseExceptionGroup
- coroutines (from generators)
- dict
- enumerate
- frozendict
- frozenset
- generators (and async generators)
- list
- memoryview
- set
- slice
- tuple

Special cases:

- union objects are now documented as "supporting class-level []",
  rather than anything to do with generics.

- Templates might be generic over a single type (union, in theory) or
  over a TypeVarTuple. As this is not currently fully settled, it is
  marked with a comment and a mild hint that it is a single type is used
  (namely, "type" is singular rather than "types", plural)

* Apply suggestions from code review



* Correct several class getitem docs

And expand the text for tuples.



* Add notes on generic typing of builtins

* Fix typo in tuple.__class_getitem__ docstring

* Typo fix: malformed refs

Fix `generic` links which weren't marked as `:ref:`.

* Strike unnecessary docs on generic-ness



* Apply suggestions from code review

These are applied at both the originally indicated locations and in the
corresponding docstring definitions.



* Update Doc/library/re.rst



* Update Objects/enumobject.c



* Remove tuple generic doc in 'stdtypes' page

This is covered in more detail in the cross-linked typing documentation.
The other copy of this documentation -- in the docstring for
`tuple.__class_getitem__` -- is left in place.

* Fix whitespace around new doc of generics

Per review, do not introduce or remove whitespace such that section
breaks are altered by the introduction of doc on various generic types.

In most cases, this is a removal of an extra line.

In one case (Arrays), it is the reintroduction of a line.

Additionally, two other minor fixes are included:
- incorrect indent on 'defaultdicts'
- make `mappingproxy.__class_getitem__.__doc__` consistent with other
  mapping type generic docs



* Move placement of memoryview generic note

Previous placement was at the end of the main docstring, which is
consistent with other types but places it after a section on various
methods (which makes it read somewhat inconsistently). Moving it up
helps resolve.



* Ensure sphinxdoc does not start sentences lowercase

Lowercase class names at the start of sentences are marked out with the
`class` role. In the case of `deque`, documentation already refers to
these as `Deques`, so this form is preferred.

* Apply suggestions from code review



* Fix line endings and wrap more tightly

Line endings fixed by pre-commit ; also re-wrapped the MappingProxyType
text which was too long.

* Use 'ContextVars' style in sphinx doc

---------
(cherry picked from commit 50fe49c879)

Co-authored-by: Stephen Rosen <sirosen@globus.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <906600+JelleZijlstra@users.noreply.github.com>
Co-authored-by: Alex Waygood <66076021+AlexWaygood@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-06-02 20:40:52 +00:00
Miss Islington (bot) 042428f443 [3.15] gh-150644: Tag Apple system log messages as public. (GH-150645) (#150738)
macOS 26 changed the default visibility of "dynamic" system messages. This
changes the logging strategy to tag all messages as "public" so they are
visible in the system log without special configuration.
(cherry picked from commit 71fc4c66d3)

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
2026-06-01 22:53:51 +00:00
Pablo Galindo Salgado d5381e18b8 [3.15] gh-149619: Harden _remote_debugging error paths (GH-150349) (#150435)
(cherry picked from commit a5be25d3bd)
2026-05-25 23:02:37 +00:00
Miss Islington (bot) e2362aac34 [3.15] gh-149156: Fix perf trampoline crash after fork (GH-150347) (#150394) 2026-05-25 19:19:22 +01:00
Miss Islington (bot) acd402ecdb [3.15] gh-150374: Fix double release of import lock in lazy import reification (GH-150376) (#150378)
gh-150374: Fix double release of import lock in lazy import reification (GH-150376)
(cherry picked from commit 5498eba545)

Co-authored-by: pengyu lee <lipengyu@kylinos.cn>
2026-05-25 09:36:22 +00:00
Serhiy Storchaka cf73b17adf [3.15] gh-150285: Fix too long docstrings in Argument Clinic code (GH-150338) (GH-150350)
(cherry picked from commit 287c98f4cb)
2026-05-24 22:31:19 +03:00
Miss Islington (bot) d52dad6989 [3.15] gh-149619: Fix _remote_debugging permissions error on Linux (GH-150012) (#150339)
gh-149619: Fix `_remote_debugging` permissions error on Linux (GH-150012)

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-05-24 13:39:29 +00:00
Miss Islington (bot) ef89cf56cc [3.15] gh-150285: Fix too long docstrings in builtins (GH-150293) (GH-150336)
(cherry picked from commit e1e06be119)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-24 16:24:57 +03:00
Miss Islington (bot) 22c994cc92 [3.15] gh-149335: Avoid JIT trace buffer asserts with overhead above FITNESS_INITIAL (GH-149633) (#150245)
gh-149335: Avoid JIT trace buffer asserts with overhead above `FITNESS_INITIAL` (GH-149633)
(cherry picked from commit 441af3a934)

Co-authored-by: Hai Zhu <haiizhu@outlook.com>
2026-05-24 12:48:58 +05:30
Miss Islington (bot) 6b17d1a783 [3.15] gh-150178: Fix refcount leaks in hamt allocation failure paths (GH-150179) (#150303)
gh-150178: Fix refcount leaks in hamt allocation failure paths (GH-150179)
(cherry picked from commit 32823af153)

Co-authored-by: pengyu lee <lipengyu@kylinos.cn>
2026-05-23 19:27:27 +00:00
Miss Islington (bot) ad2f0cb997 [3.15] PEP 810 - Update some error strings (GH-150126) (#150135) 2026-05-20 15:17:28 +00:00
Miss Islington (bot) 034c536d56 [3.15] gh-149584: Fix excessive overhead in the Tachyon profiler regarding the cache behavior (GH-149649) (#150152) 2026-05-20 11:59:10 +00:00
Dino Viehland 6847f4bc60 [3.15] gh-150052: Resolve un-loaded lazily loaded submodules via module.__getattr__ instead of publishing lazy values (#150055) 2026-05-19 21:23:30 +00:00
Dino Viehland 94c8bac2cd [3.15] gh-148587: Make sys.lazy_modules match PEP and keep internal lazy submodules tra… (#150014)
Make sys.lazy_modules match PEP and keep internal lazy submodules tracking internal
2026-05-18 17:53:54 -07:00
Miss Islington (bot) 63a4007d25 [3.15] gh-149685: Use the _Py prefix for private C macros (GH-149686) (GH-149790)
(cherry picked from commit 125f26358a)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-05-13 23:29:08 +02:00
Miss Islington (bot) 15a597e9ba [3.15] gh-149642: Fix interaction between exec and lazy_imports=all (GH-149643) (#149749)
gh-149642: Fix interaction between exec and lazy_imports=all (GH-149643)
(cherry picked from commit 4087ff8599)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-05-13 03:36:32 +00:00
Miss Islington (bot) 564902ea8a [3.15] gh-139808: Add branch protections for aarch64 in asm_trampoline.S (GH-130864) (#149730)
gh-139808: Add branch protections for aarch64 in asm_trampoline.S (GH-130864)

Apply protection against ROP/JOP attacks for aarch64 on asm_trampoline.S.

The BTI flag must be applied in assembler sources for this class
of attacks to be mitigated on newer aarch64 processors.

See also:
https://sourceware.org/annobin/annobin.html/Test-branch-protection.html
and
https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/enabling-pac-and-bti-on-aarch64
(cherry picked from commit da8477b25c)

Co-authored-by: stratakis <cstratak@redhat.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-05-12 22:10:24 +02:00
Miss Islington (bot) e2e9cea769 [3.15] GH-149501: Fix compilation warning in _YIELD_VALUE uop (GH-149502) (#149737)
GH-149501: Fix compilation warning in `_YIELD_VALUE` uop (GH-149502)
(cherry picked from commit 1a79fd0ad6)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
2026-05-12 17:58:31 +00:00
Sam Gross 8297d50a63 [3.15] gh-145235: Make dict watcher API thread-safe for free-threaded builds (gh-145233) (#149690)
In free-threaded builds, concurrent calls to PyDict_AddWatcher, PyDict_ClearWatcher, PyDict_Watch, and PyDict_Unwatch can race on the shared callback array and the per-dict watcher tags. This change adds a mutex to serialize watcher registration and removal, atomic operations for tag updates, and atomic acquire/release synchronization for callback dispatch in _PyDict_SendEvent.

(cherry picked from commit 8a4895985f)

Co-authored-by: Alper <alperyoney@fb.com>
2026-05-11 14:23:39 -04:00
Miss Islington (bot) f9e5975deb [3.15] gh-149459: Fix segfault when _LOAD_SPECIAL guard deoptimizes (GH-149478) (#149552)
gh-149459: Fix segfault when `_LOAD_SPECIAL` guard deoptimizes (GH-149478)
(cherry picked from commit c341e341b2)

Co-authored-by: Hai Zhu <haiizhu@outlook.com>
2026-05-08 11:48:04 +00:00
Miss Islington (bot) 5cb915da44 [3.15] gh-149481: skip FOR_ITER inline specialization for Python __next__ (GH-149491) (#149523)
gh-149481: skip `FOR_ITER` inline specialization for Python `__next__` (GH-149491)
(cherry picked from commit 49918f5b0c)

Co-authored-by: Neko Asakura <neko.asakura@outlook.com>
Co-authored-by: Savannah Ostrowski <savannah@python.org>
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-05-07 19:08:12 -07:00
Neil Schemenauer 13188dbf85 gh-148937: revert process RSS based GC deferral (#149475) 2026-05-07 14:32:14 +03:00
Peter Bierma 2b7c28a440 gh-149101: Implement PEP 788 (GH-149116)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
2026-05-06 17:39:30 -04:00
Alex Malyshev 646853df13 gh-145559: Add PyUnstable_DumpTraceback() and PyUnstable_DumpTracebackThreads() (#148145)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-05-06 15:01:12 +00:00
Daniele Parmeggiani 1bdfc0f253 gh-146270: Fix PyMember_SetOne(..., NULL) not being atomic (gh-148800)
Fixes a sequential consistency bug whereby two threads that are deleting a struct member may observe both their deletions to be successful.
2026-05-06 09:50:24 -04:00
Hugo van Kemenade e7613f2735 gh-148766: Add colour to Python help (#148767) 2026-05-06 16:48:04 +03:00
Wulian233 0b75b7338d gh-100239: specialize mixed int/float inplace binary ops (GH-149413) 2026-05-06 13:59:08 +01:00
Mark Shannon 70bd1c2dd2 GH-143732: SEND specialization (GH-148963)
* SEND specialization. Adds 2 new specialized instructions:

* SEND_VIRTUAL: for sends to virtual iterators e.g lists and tuples
* SEND_ASYNC_GEN: for sends to async generators

Tweak FOR_ITER_VIRTUAL so that SEND_VIRTUAL and FOR_ITER_VIRTUAL use equivalent guards
2026-05-05 15:19:16 +01:00
Diego Russo 1e5d94274d GH-126910: Add GNU backtrace support for unwinding JIT frames (#149104)
Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2026-05-05 09:29:07 +01:00