Commit graph

9919 commits

Author SHA1 Message Date
adam j hartz
d1d526afe7
gh-136251: Improvements to WASM demo REPL (GH-136252)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2025-07-21 11:56:45 +02:00
Sergey Muraviov
cf19b6435d
gh-134411: assert PyLong_FromLong(x) != NULL when x is known to be small (#134415)
Since `PyLong_From Long(PY_MONITORING_DEBUGGER_ID)` falls to `small_int` case and can't return `NULL`. Added `assert`s for extra confidence.
https://github.com/python/cpython/issues/134411#issuecomment-2897653868
2025-07-21 11:59:06 +03:00
Dave Peck
c5e77af131
gh-132661: Disallow Template/str concatenation after PEP 750 spec update (#135996)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2025-07-21 08:44:26 +02:00
Hood Chatham
800d37feca
gh-124621: Emscripten: Fix regression in use-after-close error handling (#136837) 2025-07-19 21:43:50 +02:00
Hood Chatham
7ae4749d06
gh-124621: Emscripten: Add support for async input devices (GH-136822)
This is useful for implementing proper `input()`. It requires the
JavaScript engine to support the wasm JSPI spec which is now stage 4.
It is supported on Chrome since version 137 and on Firefox and node
behind a flag.

We override the `__wasi_fd_read()` syscall with our own variant that
checks for a readAsync operation. If it has it, we use our own async
variant of `fd_read()`, otherwise we use the original `fd_read()`.
We also add a variant of `FS.createDevice()` called
`FS.createAsyncInputDevice()`.

Finally, if JSPI is available, we wrap the `main()` symbol with
`WebAssembly.promising()` so that we can stack switch from `fd_read()`.
If JSPI is not available, attempting to read from an AsyncInputDevice
will raise an `OSError`.
2025-07-19 17:14:29 +02:00
Hood Chatham
12e52cad71
gh-127146: Emscripten: Make os.umask() actually work (#136706)
Provide a stub implementation of umask that is enough to get some tests passing.
More work is needed upstream in Emscripten to make all umask tests to pass.
2025-07-16 15:33:15 +02:00
Hood Chatham
e81c4e84b3
gh-127146: Report uid in Emscripten + node as native uid (#136509)
Corrects the handling of getuid on emscripten, which was consistently reporting as 0.
2025-07-16 06:17:16 +02:00
andrewreds
2500eb96b2
gh-135909: Assert incoming refcnt != 0 for the free threaded GC (GH-136009)
This helps catch double deallocation bugs and is similar to the
assertion in the GIL-enabled build.  The call to `validate_refcounts`
is moved up to start of the GC because `queue_untracked_obj_decref()`
creates it own zero reference count garbage.
2025-07-15 11:26:16 -04:00
Adam Turner
c89a66feb1
GH-133711: Enable UTF-8 mode by default (PEP 686) (#133712)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-07-15 10:45:41 +01:00
Tian Gao
db2032407a
Fix a minor indentation error (#136661) 2025-07-14 17:01:56 -07:00
Brandt Bucher
3d8c38f6db
GH-135904: Improve the JIT's performance on macOS (GH-136528) 2025-07-14 10:14:20 -07:00
Serhiy Storchaka
da699ed7e5
gh-121914: Change the names of the symbol tables for lambda and genexpr (GH-135288)
Change the names of the symbol tables for lambda expressions and generator
expressions to "<lambda>" and "<genexpr>" respectively to avoid conflicts
with user-defined names.
2025-07-13 21:09:42 +03:00
Serhiy Storchaka
e18829a8ad
gh-132629: Deprecate accepting out-of-range values for unsigned integers in PyArg_Parse (GH-132630)
For unsigned integer formats in the PyArg_Parse* functions,
accepting Python integers with value that is larger than
the maximal value the corresponding C type or less than
the minimal value for the corresponding signed integer type
is now deprecated.
2025-07-13 12:44:54 +03:00
Weilin Du
561212a033
Doc: More duplicate word fixes (GH-136299) 2025-07-11 21:18:47 +03:00
Pablo Galindo Salgado
236f733d8f
gh-136541: Fix several problems of perf trampolines in x86_64 and aarch64 (#136500)
This commit fixes the following problems:

* The x86_64 trampolines are not preserving frame pointers
* The hardcoded offsets to the code segment from the FDE only worked properly for x64_64
* The CIE data was not following conventions of aarch64
* The eh_frame for aarch64 was not fully correct
2025-07-11 14:32:35 +01:00
Sergey Miryanov
c560df9658
gh-136517: Print uncollectable objects if DEBUG_UNCOLLECTABLE mode was set (#136518) 2025-07-10 22:13:23 +01:00
László Kiss Kollár
59acdba820
gh-135953: Implement sampling tool under profile.sample (#135998)
Implement a statistical sampling profiler that can profile external
Python processes by PID. Uses the _remote_debugging module and converts
the results to pstats-compatible format for analysis.


Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2025-07-10 18:44:24 +01:00
Pablo Galindo Salgado
77d25e5b16
gh-91048: Revert the memory cache removal for remote debugging (#136440)
gh-91048: Reintroduce the memory cache for remote debugging
2025-07-09 00:31:17 +00:00
Neil Schemenauer
b6b99bf7f1
GH-91636: Clear weakrefs created by finalizers. (GH-136401)
Weakrefs to unreachable garbage that are created during running of
finalizers need to be cleared.  This avoids exposing objects that
have `tp_clear` called on them to Python-level code.
2025-07-08 12:19:57 -07:00
Kumar Aditya
89f06a38c0
gh-134043: use _PyObject_GetMethodStackRef in pattern matching (#136356) 2025-07-08 13:04:50 +05:30
Hugo van Kemenade
fbef0c1d6a
gh-102567: Add missing newline to --help-all (GH-136391) 2025-07-08 07:59:00 +02:00
Kumar Aditya
0c3e3da195
gh-109700: fix interpreter finalization while handling memory error (#136342) 2025-07-07 12:45:22 +05:30
Kumar Aditya
85f092f541
gh-115999: remove redundant check in free-threading from _STORE_ATTR_WITH_HINT (#136249) 2025-07-04 09:04:47 +05:30
Kirill Podoprigora
a525ba514a
Python/gc.c: Refer to InternalDocs instead of devguide. (#136243) 2025-07-03 12:14:14 +00:00
Ken Jin
b3308973e3
gh-136183: Deal with escapes in JIT optimizer's constant evaluator (GH-136184) 2025-07-02 14:08:25 +08:00
Sam Gross
f41e9c750e
gh-134009: Expose PyMutex_IsLocked in the public C API (gh-134365)
The `PyMutex_IsLocked()` function is useful in assertions for verifying
that code maintains certain locking invariants.
2025-07-01 13:26:13 -04:00
Serhiy Storchaka
86c3316183
gh-134280: Disable constant folding for ~ with a boolean argument (GH-134982)
This moves the deprecation warning from compile time to run time.
2025-07-01 20:24:04 +03:00
Ken Jin
e0d6500b2d
gh-136125: Use _PyObject_GetMethodStackRef for LOAD_ATTR (GH-136127) 2025-07-02 01:20:46 +08:00
Stan Ulbrych
93809a918f
gh-105456: Remove 3 deprecated sre_* modules (#135994) 2025-07-01 17:31:07 +02:00
Victor Stinner
28940e8e48
gh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (#135928)
Move PYOS_LOG2_STACK_MARGIN, PYOS_STACK_MARGIN,
PYOS_STACK_MARGIN_BYTES and PYOS_STACK_MARGIN_SHIFT macros to
pycore_pythonrun.h internal header. Add underscore (_) prefix to the
names to make them private. Rename _PYOS to _PyOS.
2025-07-01 15:18:17 +02:00
Petr Viktorin
fe119a0817
gh-87135: threading.Lock: Raise rather than hang on Python finalization (GH-135991)
After Python finalization gets to the point where no other thread
can attach thread state, attempting to acquire a Python lock must hang.
Raise PythonFinalizationError instead of hanging.
2025-07-01 10:57:42 +02:00
Akshat Gupta
30ba03ea8e
gh-136053: Check error for TYPE_SLICE in marshal.c (GH-136054)
Fix a possible crash when deserializing a large marshal data
(at least several GiBs) containing a slice.
2025-06-29 10:07:24 +03:00
Pablo Galindo Salgado
5334732f9c
gh-91048: Fix external inspection multi-threaded performance (#136005) 2025-06-28 14:11:31 +01:00
Ken Jin
ff7b5d44a0
gh-132732: Fix up pure types in JIT (GH-136050)
Fix up pure types in JIT
2025-06-28 18:30:30 +08:00
Ken Jin
c419af9e27
gh-132732: JIT: Only allow compact ints in pure evaluation (GH-136040) 2025-06-28 00:18:44 +08:00
Ken Jin
695ab61351
gh-132732: Automatically constant evaluate pure operations (GH-132733)
This adds a "macro" to the optimizer DSL called "REPLACE_OPCODE_IF_EVALUATES_PURE", which allows automatically constant evaluating a bytecode body if certain inputs have no side effects upon evaluations (such as ints, strings, and floats).


Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-06-27 19:37:44 +08:00
Joseph Tibbertsma
cbfaf41caf
Fix needless spinning in _PyMutex_LockTimed with zero timeout (gh-135872)
The free threading build could spin unnecessarily on `_Py_yield()` if the initial
compare and swap failed.
2025-06-25 16:41:36 +00:00
Petr Viktorin
1b1ae82fab
gh-135755: Move SPECIAL_ constants to a private header (GH-135922)
Macros without a `Py`/`_Py` prefix should not be defined in public headers.
2025-06-25 13:03:05 +02:00
Neil Schemenauer
113de8545f
GH-133136: Revise QSBR to reduce excess memory held (gh-135473)
The free threading build uses QSBR to delay the freeing of dictionary
keys and list arrays when the objects are accessed by multiple threads
in order to allow concurrent reads to proceed with holding the object
lock. The requests are processed in batches to reduce execution
overhead, but for large memory blocks this can lead to excess memory
usage.

Take into account the size of the memory block when deciding when to
process QSBR requests.

Also track the amount of memory being held by QSBR for mimalloc pages.  Advance the write sequence if this memory exceeds a limit.  Advancing the sequence will allow it to be freed more quickly.

Process the held QSBR items from the "eval breaker", rather than from `_PyMem_FreeDelayed()`.  This gives a higher chance that the global read sequence has advanced enough so that items can be freed.

Co-authored-by: Sam Gross <colesbury@gmail.com>
2025-06-25 00:06:32 -07:00
Brian Schubert
4e6f0d116e
gh-135855: Raise TypeError When Passing Non-dict Object to _interpreters.set___main___attrs (gh-135856) 2025-06-24 12:53:14 -06:00
Neil Schemenauer
ceae4edf81
gh-119786: Add InternalDocs/qsbr.md. (gh-135411)
Add internal doc for the Quiescent-State Based Reclamation (QSBR) implementation.
2025-06-23 22:09:40 +00:00
Noam Cohen
bda121862e
gh-131798: Optimize _UNARY_NEGATIVE (GH-135223) 2025-06-24 03:42:09 +08:00
Ken Jin
569fc6870f
gh-134584: Specialize POP_TOP by reference and type in JIT (GH-135761) 2025-06-24 00:57:14 +08:00
sobolevn
8ca1e4d846
gh-135645: Added supports_isolated_interpreters to sys.implementation (#135667)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2025-06-21 10:56:14 +03:00
Tomas R.
61532b4bc7
gh-131798: JIT: Optimize _CALL_LEN when the length is known (#135260)
* Add news entry

* Optimize _CALL_LEN

* Simplify tests
2025-06-20 18:21:39 +02:00
Ken Jin
b53b0c14da
gh-135608: Add a null check for attribute promotion to fix a JIT crash (GH-135613)
Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
2025-06-20 14:33:35 +08:00
Nadeshiko Manju
1ddfe59320
gh-135543: Emit sys.remote_exec audit event when sys.remote_exec is called (GH-135544) 2025-06-19 21:23:38 +01:00
Ken Jin
0243260284
gh-135379: Move PyLong_CheckCompact to private header and rename it (GH-135707) 2025-06-19 13:09:09 +00:00
Mark Shannon
9731dd2c8d
GH-135379: Specialize int operations for compact ints only (GH-135668) 2025-06-19 11:10:29 +01:00
Eric Snow
725da50520
gh-133485: Use interpreters.Interpreter in InterpreterPoolExecutor (gh-133957)
Most importantly, this resolves the issues with functions and types defined in __main__.
It also expands the number of supported objects and simplifies the implementation.
2025-06-18 17:57:14 -06:00