Commit graph

9894 commits

Author SHA1 Message Date
Hood Chatham
2629ee4eb0
gh-128627: Use __builtin_wasm_test_function_pointer_signature for Emscripten trampoline (#137470)
With https://github.com/llvm/llvm-project/pull/150201 being merged, there is 
now a better way to generate the Emscripten trampoline, instead of including 
hand-generated binary WASM content. Requires Emscripten 4.0.12.
2025-09-17 15:33:55 +01:00
Sam Gross
90fe3250f8
gh-137433: Fix deadlock with stop-the-world and daemon threads (gh-137735)
There was a deadlock originally seen by Memray when a daemon thread
enabled or disabled profiling while the interpreter was shutting down.
I think this could also happen with garbage collection, but I haven't
seen that in practice.

The daemon thread could be hung while trying acquire the global rwmutex
that prevents overlapping global and per-interpreter stop-the-world events.
Since it already held the main interpreter's stop-the-world lock, it
also deadlocked the main thread, which is trying to perform interpreter
finalization.

Swap the order of lock acquisition to prevent this deadlock.
Additionally, refactor `_PyParkingLot_Park` so that the global buckets
hashtable is left in a clean state if the thread is hung in
`PyEval_AcquireThread`.
2025-09-16 09:21:58 +01:00
Ken Jin
46f823bb81
gh-132732: Clear errors in JIT optimizer on error (GH-136048) 2025-09-15 17:24:37 +01:00
Savannah Bailey
9c9a0f7da7
GH-132732: Use pure op machinery to optimize various instructions with _POP_TOP and _POP_TWO (#137577) 2025-09-15 16:29:45 +01:00
sobolevn
baf7470515
gh-138886: Remove deprecated PySys_ResetWarnOptions C-API function (#138887) 2025-09-15 12:01:33 +03:00
sobolevn
1c984ba953
gh-136355: Deprecate -b and -bb CLI flags in 3.15 (#136363)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-09-14 20:00:03 +03:00
Kumar Aditya
ea26f6da39
gh-138661: fix data race in PyCode_Addr2Line (#138664) 2025-09-12 18:04:55 +05:30
Victor Stinner
3d521a62e7
gh-138756: Fix leak of inittab memory in PyInitConfig_Free() (GH-138792) 2025-09-12 11:46:02 +02:00
Victor Stinner
96dee64c73
gh-138756: Fix memory leak in PyInitConfig_Free() (#138759)
Clear also memory of PyConfig members.
2025-09-11 10:46:19 +00:00
Jelle Zijlstra
7a6fd4a45d
gh-138349: Fix crash when combining module-level annotation and listcomp (#138363) 2025-09-10 15:18:39 +02:00
Dino Viehland
04c7f36205
gh-138230: Remove dead code in code gen - codegen_check_annotation is only calle… (#138228)
Remove dead code in code gen - codegen_check_annotation is only called if future annotations are enabled, and if future annotations are enabled it does nothing.
2025-09-09 18:17:00 -07:00
Serhiy Storchaka
af58a6f883
gh-88886: Remove excessive encoding name normalization (GH-137167)
The codecs lookup function now performs only minimal normalization of
the encoding name before passing it to the search functions:
all ASCII letters are converted to lower case, spaces are replaced
with hyphens.

Excessive normalization broke third-party codecs providers, like
python-iconv.

Revert "bpo-37751: Fix codecs.lookup() normalization (GH-15092)"

This reverts commit 20f59fe1f7.
2025-09-09 21:07:21 +03:00
Petr Viktorin
a92aec101e
gh-133143: Use _Py_ID for the other literals in sys (GH-138698)
Follow-up refactoring after GH-133143, where we use `_Py_ID` for "big" and "little"
in `abi_info.byteorder`.
This uses `_Py_ID` for `sys.byteorder`, but also `float_repr_style` and a module name.
2025-09-09 14:57:07 +02:00
Donghee Na
5edfe55acf
gh-137838: Fix JIT trace buffer overrun by increasing possible exit stubs (gh-138177) 2025-09-09 09:51:08 +09:00
Dino Viehland
1561385863
gh-138679: Opcodes which consume no inputs should indicate they produced the val… (#138678)
Opcodes which consume no inputs should indicate they produced the value, not an arbitrary local
2025-09-08 13:53:12 -07:00
Adam Turner
5443b9e52f
gh-133143: Condense the implementation for `sys.abi_info` (#138672) 2025-09-08 19:21:28 +00:00
Klaus Zimmermann
1acb718ea2
gh-133143: Add sys.abi_info (GH-137476)
This makes information about the interpreter ABI more accessible.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-08 14:35:44 +00:00
mqudah
2f5ace780b
fix comment reference from man 7 signal to man 7 signal-safety (#138554)
docs: fix comment reference from man 7 signal to man 7 signal-safety
2025-09-06 18:40:15 +00:00
Petr Viktorin
0c74fc8af0
gh-137210: Add a struct, slot & function for checking an extension's ABI (GH-137212)
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
2025-09-05 16:23:18 +02:00
Donghee Na
f070f54c5f
gh-138192: Fix Context initialization so that all subinterpreters are assigned the MISSING value. (gh-138503)
---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-09-04 17:19:30 +00:00
Ken Jin
2402f84665
gh-138431: JIT Optimizer --- Fix round-tripping references for str and tuple (GH-138458)
Co-authored-by: Mark Shannon <9448417+markshannon@users.noreply.github.com>
2025-09-04 02:05:06 +08:00
AN Long
1ff2cbbac8
gh-137136: Suppress build warnings when build on Windows with --experimental-jit-interpreter (GH-137137) 2025-09-03 15:42:26 +01:00
Serhiy Storchaka
4a33077fdb
gh-138264: Fix gcc 14 compiler warnings (GH-138265) 2025-09-03 11:26:56 +03:00
Brian Schubert
5493b46462
gh-138372: Fix SyntaxWarning for erroneous t-string subscription (#138375) 2025-09-02 18:13:12 +01:00
Christoph Walcher
47bc10e6b3
gh-135763: AC: Implement `allow_negative for Py_ssize_t` (#138150)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-01 22:55:22 +01:00
Tapeline
ea77feecbb
gh-138302: Specialize int ops only if ints are compact (GH-138347) 2025-09-02 01:33:15 +08:00
Dino Viehland
e05182f98e
gh-138250: load fast optimization should fall through to empty blocks (#138249)
load fast optimization should fall through to empty blocks
2025-08-29 11:49:35 -07:00
Pablo Galindo Salgado
56eb6b64a0
gh-138122: Implement PEP 799 (#138142) 2025-08-27 17:52:50 +01:00
Serhiy Storchaka
b8c90e72b3
gh-137609: Change names of some positional-only parameters in builtins (GH-137611)
This is for a pair with GH-137610.
2025-08-25 15:36:06 +03:00
Kumar Aditya
b9bcd02e9f
gh-137384: fix crash when accessing warnings state late in runtime shutdown (#138027) 2025-08-22 19:10:43 +05:30
Mark Shannon
a8d9d94784
GH-137959: Replace shim code in jitted code with a single trampoline function. (GH-137961) 2025-08-21 10:40:53 +01:00
Yüce Tekol
7dc42b67a7
gh-137884: Added threading.get_native_id() on Illumos/Solaris (GH-137927) 2025-08-20 17:10:44 +00:00
Ken Jin
7fda8b66de
gh-137728 gh-137762: Fix bugs in the JIT with many local variables (GH-137764) 2025-08-20 22:53:54 +08:00
Peter Bierma
b07a267953
gh-137883: Check the recursion limit for specialized keyword argument calls (GH-137887) 2025-08-19 09:53:38 +01:00
Adam Turner
918e3ba6c0
GH-137623: Use an AC decorator for docstring line length enforcement (#137690) 2025-08-18 18:29:00 +01:00
Petr Viktorin
7dfa048bbb
gh-135228: Create __dict__ and __weakref__ descriptors for object (GH-136966)
This partially reverts #137047, keeping the tests for GC collectability of the
original class that dataclass adds `__slots__` to.
The reference leaks solved there are instead solved by having the `__dict__` &
`__weakref__` descriptors not tied to (and referencing) their class.

Instead, they're shared between all classes that need them (within
an interpreter).
The `__objclass__` ol the descriptors is set to `object`, since these
descriptors work with *any* object. (The appropriate checks were already
made in the get/set code, so the `__objclass__` check was redundant.)

The repr of these descriptors (and any others whose `__objclass__` is `object`)
now doesn't mention the objclass.

This change required adjustment of introspection code that checks
`__objclass__` to determine an object's “own” (i.e. not inherited) `__dict__`.
Third-party code that does similar introspection of the internals will also
need adjusting.


Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2025-08-18 14:25:51 +02:00
adam j hartz
04f8ef663b
gh-137576: Fix for Basic REPL showing incorrect code in tracebacks with PYTHONSTARTUP (#137625)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2025-08-14 20:58:11 +03:00
Serhiy Storchaka
c47ffbf1a3
gh-125854: Improve error messages for invalid category in the warnings module (GH-137750)
Include the type name if the category is a type, but not a Warning
subclass, instead of just 'type'.
2025-08-14 14:59:04 +03:00
Sachin Shah
c9d7065188
GH-137573: mark _PyOptimizer_Optimize as no inline (GH-137731)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-08-14 08:00:00 +00:00
Sam Gross
a10152f8fd
gh-137400: Fix thread-safety issues when profiling all threads (gh-137518)
There were a few thread-safety issues when profiling or tracing all
threads via PyEval_SetProfileAllThreads or PyEval_SetTraceAllThreads:

* The loop over thread states could crash if a thread exits concurrently
  (in both the free threading and default build)
* The modification of `c_profilefunc` and `c_tracefunc` wasn't
  thread-safe on the free threading build.
2025-08-13 14:15:12 -04:00
Dino Viehland
b78e9c05b6
gh-137681: Always initialize exception handler for new instruction (#137655)
Always initialize exception handler for new instruction
2025-08-13 08:58:26 -07:00
Serhiy Storchaka
35759fe2fa
gh-137668: Document that ord() supports also bytes and bytearray (GH-137669) 2025-08-13 12:12:16 +03:00
Sergey Miryanov
654b8d9364
GH-137562: Fix github-issue number for deallocated objects in cache bug (GH-137614) 2025-08-12 10:32:53 -07:00
Jelle Zijlstra
6859b95cff
gh-135228: When @dataclass(slots=True) replaces a dataclass, make the original class collectible (take 2) (GH-137047)
Remove the `__dict__` and `__weakref__` descriptors from the original class when creating a dataclass from it.

An interesting hack, but more localized in scope than gh-135230.

This may be a breaking change if people intentionally keep the original class around
when using `@dataclass(slots=True)`, and then use `__dict__` or `__weakref__` on the
original class.


Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-08-12 13:16:54 +02:00
Sam Gross
362692852f
gh-137400: Fix a crash when disabling profiling across all threads (gh-137471)
The `PyEval_SetProfileAllThreads` function and other related functions
had a race condition on `tstate->c_profilefunc` that could lead to a
crash when disable profiling or tracing on all threads while another
thread is starting to profile or trace a a call.

There are still potential crashes when threads exit concurrently with
profiling or tracing be enabled/disabled across all threads.
2025-08-11 11:41:44 -04:00
László Kiss Kollár
4497ad409e
gh-135953: Profile a module or script with sampling profiler (#136777) 2025-08-11 12:36:43 +01:00
Mark Shannon
af15e1d13e
GH-132532: Add new DSL macros to better declare semantics of exits at ends of instructions/uops. (GH-137098) 2025-08-09 15:41:28 +01:00
Sergey Miryanov
c744b57fd6
gh-137562: Remove reference for GC_REACHABLE in comment (GH-137563)
GC_REACHABLE is obsolete
2025-08-09 21:32:45 +09:00
Neil Schemenauer
350c58ba4e
GH-135552: Make the GC clear weakrefs later (GH-136189)
Fix a bug caused by the garbage collector clearing weakrefs too early.  The
weakrefs in the ``tp_subclasses`` dictionary are needed in order to correctly
invalidate type caches (for example, by calling ``PyType_Modified()``).
Clearing weakrefs before calling finalizers causes the caches to not be
correctly invalidated.  That can cause crashes since the caches can refer to
invalid objects.  Defer the clearing of weakrefs without callbacks until after
finalizers are executed.
2025-08-07 16:32:17 -07:00
Dino Viehland
375f484f97
gh-137291: Support perf profiler with an evaluation hook (#137292)
Support perf profiler with an evaluation hook
2025-08-07 14:54:12 -07:00