summaryrefslogtreecommitdiffstats
path: root/Modules
Commit message (Collapse)AuthorAgeFilesLines
* gh-142595: Amend be5e0dcdedb (fix NULL pointer dereference) (GH-142775)Sergey B Kirpichev13 days1-2/+3
|
* gh-116738: Make _bz2 module thread-safe (gh-142756)Alper13 days1-6/+25
| | | | | Make the attributes in _bz2 module thread-safe on the free-threading build. Attributes (eof, needs_input, unused_data) are now stored atomically or accessed via mutex-protected getters.
* gh-142594: fix by property calls io.TextIOWrapper.detach (GH-142706)yihong14 days1-0/+3
| | | | Signed-off-by: yihong0618 <zouzou0208@gmail.com>
* gh-138122: Add --subprocesses flag to profile child processes in tachyon ↵Pablo Galindo Salgado14 days5-16/+709
| | | | (#142636)
* gh-76007: Deprecate `__version__` attribute in `ctypes` (#142679)Hugo van Kemenade14 days2-1/+24
|
* gh-140414: streamline thread state access in `asyncio` (#142742)Kumar Aditya14 days1-31/+31
|
* gh-142451: correctly copy HMAC attributes in `HMAC.copy()` (#142510)Bénédikt Tran2025-12-141-3/+11
|
* gh-116738: Make zlib module thread-safe (gh-142432)Alper2025-12-121-54/+79
| | | | | | Makes the zlib module thread-safe free-threading build. Even though operations are protected by locks, attributes exposed via PyMemberDef (eof, needs_input, unused_data, unconsumed_tail) should still be stored atomically within locked sections, since they can be read without acquiring the lock.
* gh-142595: add type check for namedtuple call during decimal initialization ↵Sergey B Kirpichev2025-12-121-4/+8
| | | | (GH-142608)
* gh-138122: Add exception profiling mode to the sampling profiler (#142561)Pablo Galindo Salgado2025-12-113-6/+42
|
* gh-142531: Fix free-threaded GC performance regression (gh-142562)Neil Schemenauer2025-12-111-0/+8
| | | | | | | If there are many untracked tuples, the GC will run too often, resulting in poor performance. The fix is to include untracked tuples in the "long lived" object count. The number of frozen objects is also now included since the free-threaded GC must scan those too.
* gh-142589: Fix PyUnstable_Object_IsUniqueReferencedTemporary (gh-142593)Sam Gross2025-12-111-0/+10
| | | | PyUnstable_Object_IsUniqueReferencedTemporary wasn't handling tagged ints on the evaluation stack properly.
* Fix os.posix_spawn() error handling (#142532)Bartosz Sławecki2025-12-111-1/+1
| | | Consistently use `goto exit;` in `py_posix_spawn()`.
* gh-142438: Added missing GIL release in _PySSL_keylog_callback when ↵AZero132025-12-111-1/+3
| | | | keylog_bio is unset (gh-142439)
* gh-142556: fix crash when a task gets re-registered during finalization in ↵Kumar Aditya2025-12-111-9/+5
| | | | `asyncio` (#142565)
* gh-123241: Don't modify ref count during visitation (GH-142232)Dino Viehland2025-12-111-9/+5
|
* gh-138122: Make the tachyon profiler opcode-aware (#142394)Pablo Galindo Salgado2025-12-115-45/+172
|
* Silence warning on conversion from uint64_t to uintptr_t in threads.c (#142437)AZero132025-12-091-1/+2
|
* gh-138122: Fix unused variable warning in threads.c (#142425)Sam Gross2025-12-081-0/+1
|
* gh-141770: Annotate anonymous mmap usage if "-X dev" is used (gh-142079)Donghee Na2025-12-082-1/+6
|
* gh-142207: remove assertions incompatible under `profiling.sampling` (#142331)yihong2025-12-081-4/+2
|
* gh-138122: Don't sample partial frame chains (#141912)Pablo Galindo Salgado2025-12-073-11/+25
|
* gh-138122: Implement frame caching in RemoteUnwinder to reduce memory reads ↵Pablo Galindo Salgado2025-12-068-36/+822
| | | | | | | | | | | (#142137) This PR implements frame caching in the RemoteUnwinder class to significantly reduce memory reads when profiling remote processes with deep call stacks. When cache_frames=True, the unwinder stores the frame chain from each sample and reuses unchanged portions in subsequent samples. Since most profiling samples capture similar call stacks (especially the parent frames), this optimization avoids repeatedly reading the same frame data from the target process. The implementation adds a last_profiled_frame field to the thread state that tracks where the previous sample stopped. On the next sample, if the current frame chain reaches this marker, the cached frames from that point onward are reused instead of being re-read from remote memory. The sampling profiler now enables frame caching by default.
* GH-141565: Add async code awareness to Tachyon (#141533)Savannah Ostrowski2025-12-063-6/+25
| | | | Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
* gh-115952: Fix a potential virtual memory allocation denial of service in ↵Serhiy Storchaka2025-12-051-92/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pickle (GH-119204) Loading a small data which does not even involve arbitrary code execution could consume arbitrary large amount of memory. There were three issues: * PUT and LONG_BINPUT with large argument (the C implementation only). Since the memo is implemented in C as a continuous dynamic array, a single opcode can cause its resizing to arbitrary size. Now the sparsity of memo indices is limited. * BINBYTES, BINBYTES8 and BYTEARRAY8 with large argument. They allocated the bytes or bytearray object of the specified size before reading into it. Now they read very large data by chunks. * BINSTRING, BINUNICODE, LONG4, BINUNICODE8 and FRAME with large argument. They read the whole data by calling the read() method of the underlying file object, which usually allocates the bytes object of the specified size before reading into it. Now they read very large data by chunks. Also add comprehensive benchmark suite to measure performance and memory impact of chunked reading optimization in PR #119204. Features: - Normal mode: benchmarks legitimate pickles (time/memory metrics) - Antagonistic mode: tests malicious pickles (DoS protection) - Baseline comparison: side-by-side comparison of two Python builds - Support for truncated data and sparse memo attack vectors Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
* gh-48752: Add readline.get_pre_input_hook() function (#141586)Sanyam Khurana2025-12-052-1/+48
| | | | | Add readline.get_pre_input_hook() to retrieve the current pre-input hook. This allows applications to save and restore the hook without overwriting user settings.
* gh-116738: Statically initialize special constants in cmath module (gh-142161)Alper2025-12-041-126/+99
| | | The initialization during `mod_exec` wasn't thread-safe with multiple interpreters.
* gh-116738: Fix thread-safety issue in re module for free threading (gh-141923)Alper2025-11-261-4/+9
| | | | | | | | Added atomic operations to `scanner_begin()` and `scanner_end()` to prevent race conditions on the `executing` flag in free-threaded builds. Also added tests for concurrent usage of the `re` module. Without the atomic operations, `test_scanner_concurrent_access()` triggers `assert(self->executing)` failures, or a thread sanitizer run emits errors.
* gh-138122: Split Modules/_remote_debugging_module.c into multiple files ↵Pablo Galindo Salgado2025-11-2511-3613/+4236
| | | | | (#141934) gh-1381228: Split Modules/_remote_debugging_module.c into multiple files
* gh-141780: Make PyModule_FromSlotsAndSpec enable GIL if needed (GH-141785)Petr Viktorin2025-11-242-0/+54
|
* GH-140638: Add a GC "candidates" stat (GH-141814)Brandt Bucher2025-11-221-1/+2
|
* gh-141801: Use accessors for ASN1_STRING fields in libssl (GH-141802)David Benjamin2025-11-221-8/+10
| | | | | | | | | | | | | | | | | | | | * gh-141801: Use accessors for ASN1_STRING fields While ASN1_STRING is currently exposed, it is better to use the accessors. See https://github.com/openssl/openssl/issues/29117 where, if the type were opaque, OpenSSL's X509 objects could be much more memory-efficient. * Update Modules/_ssl.c Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * Update Modules/_ssl.c Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --------- Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* gh-141817: Add IPV6_HDRINCL constant to the socket module (#141818)Chris Angelico2025-11-221-0/+3
| | | | Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* gh-116738: Make csv module thread-safe (gh-141365)Alper2025-11-211-9/+29
| | | Added a critical section to protect the states of `ReaderObj` and `WriterObj` in the free-threading build. Without the critical sections, both new free-threading tests were crashing.
* gh-141645: Add a TUI mode to the new tachyon profiler (#141646)Pablo Galindo Salgado2025-11-201-1/+7
|
* gh-60107: Remove a copy from RawIOBase.read (#141532)Cody Maloney2025-11-201-11/+11
| | | | | If the underlying I/O class keeps a reference to the memory, raise BufferError. Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-141784: Fix _remote_debugging_module.c compilation on 32-bit Linux (#141796)Victor Stinner2025-11-201-9/+12
| | | | Include Python.h before system headers to make sure that _remote_debugging_module.c uses the same types (ABI) than Python.
* gh-140042: Removing unsafe call to sqlite3_shutdown (GH-141690)Prithviraj Chaudhuri2025-11-201-1/+0
|
* GH-140638: Add a GC "duration" stat (GH-141720)Brandt Bucher2025-11-191-2/+3
|
* gh-141659: Fix bad file descriptor error in subprocess on AIX (GH-141660)Ayappan Perumal2025-11-191-0/+6
| | | /proc/self does not exist on AIX.
* gh-141070: Add PyUnstable_Object_Dump() function (#141072)Victor Stinner2025-11-181-0/+25
| | | | | | | | | | * Promote _PyObject_Dump() as a public function. * Keep _PyObject_Dump() alias to PyUnstable_Object_Dump() for backward compatibility. * Replace _PyObject_Dump() with PyUnstable_Object_Dump(). Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-135953: Simplify GC markers in the tachyon profiler (#141666)Pablo Galindo Salgado2025-11-171-11/+0
|
* GH-139914: Handle stack growth direction on HPPA (GH-140028)Stefano Rivera2025-11-171-0/+4
| | | | | | Adapted from a patch for Python 3.14 submitted to the Debian BTS by John https://bugs.debian.org/1105111#20 Co-authored-by: John David Anglin <dave.anglin@bell.net>
* GH-140643: Add `<native>` and `<GC>` frames to the sampling profiler (#141108)Brandt Bucher2025-11-172-57/+155
| | | | | | | | | - Introduce a new field in the GC state to store the frame that initiated garbage collection. - Update RemoteUnwinder to include options for including "<native>" and "<GC>" frames in the stack trace. - Modify the sampling profiler to accept parameters for controlling the inclusion of native and GC frames. - Enhance the stack collector to properly format and append these frames during profiling. - Add tests to verify the correct behavior of the profiler with respect to native and GC frames, including options to exclude them. Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
* gh-135953: Add GIL contention markers to sampling profiler Gecko format ↵Pablo Galindo Salgado2025-11-171-26/+97
| | | | | | (#139485) This commit enhances the Gecko format reporter in the sampling profiler to include markers for GIL acquisition events.
* gh-141553: Fix incorrect function signatures in `_testmultiphase` (#141554)Shamil2025-11-151-2/+3
|
* gh-114203: skip locking if object is already locked by two-mutex critical ↵Kumar Aditya2025-11-141-0/+101
| | | | section (#141476)
* gh-139109: A new tracing JIT compiler frontend for CPython (GH-140310)Ken Jin2025-11-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR changes the current JIT model from trace projection to trace recording. Benchmarking: better pyperformance (about 1.7% overall) geomean versus current https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20251108-3.15.0a1%2B-7e2bc1d-JIT/bm-20251108-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-7e2bc1d-vs-base.svg, 100% faster Richards on the most improved benchmark versus the current JIT. Slowdown of about 10-15% on the worst benchmark versus the current JIT. **Note: the fastest version isn't the one merged, as it relies on fixing bugs in the specializing interpreter, which is left to another PR**. The speedup in the merged version is about 1.1%. https://raw.githubusercontent.com/facebookexperimental/free-threading-benchmarking/refs/heads/main/results/bm-20251112-3.15.0a1%2B-f8a764a-JIT/bm-20251112-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-f8a764a-vs-base.svg Stats: 50% more uops executed, 30% more traces entered the last time we ran them. It also suggests our trace lengths for a real trace recording JIT are too short, as a lot of trace too long aborts https://github.com/facebookexperimental/free-threading-benchmarking/blob/main/results/bm-20251023-3.15.0a1%2B-eb73378-CLANG%2CJIT/bm-20251023-vultr-x86_64-Fidget%252dSpinner-tracing_jit-3.15.0a1%2B-eb73378-pystats-vs-base.md . This new JIT frontend is already able to record/execute significantly more instructions than the previous JIT frontend. In this PR, we are now able to record through custom dunders, simple object creation, generators, etc. None of these were done by the old JIT frontend. Some custom dunders uops were discovered to be broken as part of this work gh-140277 The optimizer stack space check is disabled, as it's no longer valid to deal with underflow. Pros: * Ignoring the generated tracer code as it's automatically created, this is only additional 1k lines of code. The maintenance burden is handled by the DSL and code generator. * `optimizer.c` is now significantly simpler, as we don't have to do strange things to recover the bytecode from a trace. * The new JIT frontend is able to handle a lot more control-flow than the old one. * Tracing is very low overhead. We use the tail calling interpreter/computed goto interpreter to switch between tracing mode and non-tracing mode. I call this mechanism dual dispatch, as we have two dispatch tables dispatching to each other. Specialization is still enabled while tracing. * Better handling of polymorphism. We leverage the specializing interpreter for this. Cons: * (For now) requires tail calling interpreter or computed gotos. This means no Windows JIT for now :(. Not to fret, tail calling is coming soon to Windows though https://github.com/python/cpython/pull/139962 Design: * After each instruction, the `record_previous_inst` function/label is executed. This does as the name suggests. * The tracing interpreter lowers bytecode to uops directly so that it can obtain "fresh" values at the point of lowering. * The tracing version behaves nearly identical to the normal interpreter, in fact it even has specialization! This allows it to run without much of a slowdown when tracing. The actual cost of tracing is only a function call and writes to memory. * The tracing interpreter uses the specializing interpreter's deopt to naturally form the side exit chains. This allows it to side exit chain effectively, without repeating much code. We force a re-specializing when tracing a deopt. * The tracing interpreter can even handle goto errors/exceptions, but I chose to disable them for now as it's not tested. * Because we do not share interpreter dispatch, there is should be no significant slowdown to the original specializing interpreter on tailcall and computed got with JIT disabled. With JIT enabled, there might be a slowdown in the form of the JIT trying to trace. * Things that could have dynamic instruction pointer effects are guarded on. The guard deopts to a new instruction --- `_DYNAMIC_EXIT`.
* gh-139653: Add PyUnstable_ThreadState_SetStackProtection() (#139668)Victor Stinner2025-11-131-0/+54
| | | | | | | | Add PyUnstable_ThreadState_SetStackProtection() and PyUnstable_ThreadState_ResetStackProtection() functions to set the stack base address and stack size of a Python thread state. Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-135801: Add the module parameter to compile() etc (GH-139652)Serhiy Storchaka2025-11-132-11/+66
| | | | | | | Many functions related to compiling or parsing Python code, such as compile(), ast.parse(), symtable.symtable(), and importlib.abc.InspectLoader.source_to_code() now allow to pass the module name used when filtering syntax warnings.