| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
| |
(gh-135899) (#136969)
Co-authored-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
|
| |
|
|
|
|
|
| |
update (#135996) (#136901)
Co-authored-by: Dave Peck <davepeck@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
bytecode (GH-136525) (GH-136657)
Previously, we assumed that instrumentation would happen for all copies of
the bytecode if the instrumentation version on the code object didn't match
the per-interpreter instrumentation version. That assumption was incorrect:
instrumentation will exit early if there are no new "events," even if there
is an instrumentation version mismatch.
To fix this, include the instrumented opcodes when creating new copies of
the bytecode, rather than replacing them with their uninstrumented variants.
I don't think we have to worry about races between instrumentation and creating
new copies of the bytecode: instrumentation and new bytecode creation cannot happen
concurrently. Instrumentation requires that either the world is stopped or the
code object's per-object lock is held and new bytecode creation requires holding
the code object's per-object lock.
(cherry picked from commit d995922198304a6de19ac1bec3e36d1e886d8468)
Co-authored-by: mpage <mpage@meta.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
| |
|
|
|
|
|
|
| |
search (GH-132574) (#136628)
gh-127971: fix off-by-one read beyond the end of a string during search (GH-132574)
(cherry picked from commit 85ec3b3b503ffd5b7e45f8b3fa2cec0c10e4bef0)
Co-authored-by: Duane Griffin <duaneg@dghda.com>
|
| |
|
|
|
|
|
|
|
| |
`ind.__index__` has side-effects (GH-132379) (#136581)
gh-91153: prevent a crash in `bytearray.__setitem__(ind, ...)` when `ind.__index__` has side-effects (GH-132379)
(cherry picked from commit 5e1e21dee35b8e9066692d08033bbbdb562e2c28)
Co-authored-by: Bast <52266665+bast0006@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
|
| |
|
|
|
|
| |
(GH-136441) (#136511)
Co-authored-by: Dave Peck <davepeck@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
(cherry picked from commit 113de8545ffe74a4a1dddb9351fa1cbd3562b621)
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
|
| |
|
|
| |
Co-authored-by: Mark Shannon <mark@hotpy.org>
|
| |
|
|
|
|
|
|
| |
(GH-136338) (#136340)
gh-109700: fix memory error handling in `PyDict_SetDefault` (GH-136338)
(cherry picked from commit d22e073d2b49313bbf42d40cbe74afa2b69385df)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
| |
|
|
|
|
|
|
|
|
| |
(#136266)
gh-129824: fix data races in subinterpreters under TSAN (GH-135794)
This fixes the data races in typeobject.c in subinterpreters under free-threading. The type flags and slots are only modified in the main interpreter as all static types are first initialised in main interpreter.
(cherry picked from commit b582d751b4968d4534fdb7894e50713676789b2f)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
| |
|
|
|
|
|
|
|
|
| |
extension modules and objects (#135614) (#136119)
gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614)
(cherry picked from commit b1056c2a446b43452e457d5fd5f1bde66afd3883)
Co-authored-by: Xuanteng Huang <44627253+xuantengh@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
| |
|
|
|
|
|
|
|
|
| |
not instantiable (GH-135981) (GH-136030)
Previous error message suggested to use cls.__new__(), which
obviously does not work. Now the error message is the same as for
cls(...).
(cherry picked from commit c45f4f3ebe34529a8db3a7918e8dd2e9f7ce8e86)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
| |
|
|
|
|
|
| |
(GH-135938) (GH-135972)
(cherry picked from commit 10a3d431881bb9169abde97f85ea6a670e1ef3cc)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
(#135896)
gh-135878: Fix crash in `types.SimpleNamespace.__repr__` (GH-135889)
(cherry picked from commit b3ab94acd308591bbdf264f1722fedc7ee25d6fa)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
|
| |
|
|
|
|
|
|
| |
The assertion reflected a misunderstanding of situations where "hidden" variables might exist,
namely generator expressions and comprehensions.
(cherry picked from commit 15f2bac02c5e, AKA gh-135466)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(gh-135593)
For several builtin functions, we now fall back to __main__.__dict__ for the globals
when there is no current frame and _PyInterpreterState_IsRunningMain() returns
true. This allows those functions to be run with Interpreter.call().
The affected builtins:
* exec()
* eval()
* globals()
* locals()
* vars()
* dir()
We take a similar approach with "stateless" functions, which don't use any
global variables.
(cherry picked from commit a450a0ddec, AKA gh-135491)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
|
| |
|
|
|
|
|
|
| |
Use `ma_used` instead of `ma_keys->dk_nentries` for modification check
so that we only check if the dictionary is modified, not if new keys are
added to a different dictionary that shared the same keys object.
(cherry picked from commit d8994b0a77cc9821772d05db00a6ab23382fa17d)
Co-authored-by: Sam Gross <colesbury@gmail.com>
|
| |
|
|
|
|
|
| |
_PyCode_SetUnboundVarCounts() (gh-135493)
(cherry picked from commit 56eabea, AKA gh-135438)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973)
Replace most PyUnicodeWriter_WriteUTF8() calls with
PyUnicodeWriter_WriteASCII().
(cherry picked from commit f49a07b531543dd8a42d90f5b1c89c0312fbf806)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
(GH-133658) (#134964)
gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658)
random.getrandbits() can now generate more that 2**31 bits.
random.randbytes() can now generate more that 256 MiB.
(cherry picked from commit 68784fed78aa297f0de0d038742495709185bef5)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
gh-132775: Fix _PyFunctIon_VerifyStateless() ()
The problem we're fixing here is that we were using PyDict_Size() on "defaults",
which it is actually a tuple. We're also adding some explicit type checks.
This is a follow-up to gh-133221/gh-133528.
(cherry picked from commit dafd14146f7, AKA gh-134900)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
|
| |
|
|
| |
(GH-134725) (#134859)
|
| |
|
|
|
|
|
|
| |
This is the same underlying bug as gh-130519. The destructor may call
arbitrary code, changing the `tstate->qsbr pointer` and invalidating the
old `struct _qsbr_thread_state`.
(cherry picked from commit a4d37f88b66bc9a66b2ab277aa66a2a6b20821fa)
Co-authored-by: Sam Gross <colesbury@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#134673)
gh-91048: Refactor and optimize remote debugging module (#134652)
Completely refactor Modules/_remote_debugging_module.c with improved
code organization, replacing scattered reference counting and error
handling with centralized goto error paths. This cleanup improves
maintainability and reduces code duplication throughout the module while
preserving the same external API.
Implement memory page caching optimization in Python/remote_debug.h to
avoid repeated reads of the same memory regions during debugging
operations. The cache stores previously read memory pages and reuses
them for subsequent reads, significantly reducing system calls and
improving performance.
Add code object caching mechanism with a new code_object_generation
field in the interpreter state that tracks when code object caches need
invalidation. This allows efficient reuse of parsed code object metadata
and eliminates redundant processing of the same code objects across
debugging sessions.
Optimize memory operations by replacing multiple individual structure
copies with single bulk reads for the same data structures. This reduces
the number of memory operations and system calls required to gather
debugging information from the target process.
Update Makefile.pre.in to include Python/remote_debug.h in the headers
list, ensuring that changes to the remote debugging header force proper
recompilation of dependent modules and maintain build consistency across
the codebase.
Also, make the module compatible with the free threading build as an extra :)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 42b25ad4d3d6bcdc28ddfe07d2bf8831378bb0d1)
|
| |
|
|
|
|
|
|
| |
(#134655)
gh-133778: Fix setting `__annotations__` under PEP 563 (GH-133794)
(cherry picked from commit 4443110c3409ecba9f0fd49495d039030cb7ed58)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
|
| |
|
|
|
|
|
|
| |
(#134354)
gh-133980: use atomic store in `PyObject_GenericSetDict` (GH-133988)
(cherry picked from commit ec39fd2c20323ee9814a1137b1a0819e92efae4e)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
| |
|
|
|
|
|
|
|
| |
iterator (GH-134120) (#134153)
gh-134119: Fix crash from calling next() on exhausted template iterator (GH-134120)
(cherry picked from commit fc7f4c36664314393bd4c30355e21bd7aeac524d)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
|
| |
|
|
|
|
| |
gh-133970: Make PEP750 types generic (GH-133976)
(cherry picked from commit c3a1da5b9397867e6b3169dd17cb33ef2898da4a)
Co-authored-by: sobolevn <mail@sobolevn.me>
|
| |
|
|
|
|
|
|
|
|
| |
(#133979)
gh-132641: fix race in `lru_cache` under free-threading (GH-133787)
Fix race in `lru_cache` by acquiring critical section on the cache object itself and call the lock held variant of dict functions to modify the underlying dict.
(cherry picked from commit 9ad0c7b0f14c5fcda6bfae6692c88abb95502d38)
Co-authored-by: Peter Hawkins <phawkins@google.com>
|
| |
|
|
|
|
|
|
|
|
| |
(#133971)
gh-133968: Add fast path to PyUnicodeWriter_WriteStr() (GH-133969)
Don't call PyObject_Str() if the input type is str.
(cherry picked from commit fe9f6e829a535747b1e06d9bfda033a9a47165ed)
Co-authored-by: Victor Stinner <vstinner@python.org>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
error handler (GH-129648) (GH-133942)
If the error handler is used, a new bytes object is created to set as
the object attribute of UnicodeDecodeError, and that bytes object then
replaces the original data. A pointer to the decoded data will became invalid
after destroying that temporary bytes object. So we need other way to return
the first invalid escape from _PyUnicode_DecodeUnicodeEscapeInternal().
_PyBytes_DecodeEscape() does not have such issue, because it does not
use the error handlers registry, but it should be changed for compatibility
with _PyUnicode_DecodeUnicodeEscapeInternal().
(cherry picked from commit 9f69a58623bd01349a18ba0c7a9cb1dad6a51e8e)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
| |
|
|
| |
(cherry picked from commit 92337f666e8a076a68305a8d6dc8bc9c095000e9)
Co-authored-by: Inada Naoki <songofacandy@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
(gh-133685)
The function `dict_set_fromkeys()` adds elements of a set to an existing
dictionary. The size of the expanded dictionary was estimated with
`PySet_GET_SIZE(iterable)`, which did not take into account the size of the
existing dictionary.
(cherry picked from commit 421ba589d02b53131f793889d221ef3b1f1410a4)
Co-authored-by: Angela Liss <59097311+angela-tarantula@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
parsing (GH-133584) (GH-133650)
* Add Argument Clinic converters: uint8, uint16, uint32, uint64.
* Add private C API: _PyLong_UInt8_Converter(),
_PyLong_UInt16_Converter(), _PyLong_UInt32_Converter(),
_PyLong_UInt64_Converter().
(cherry picked from commit 4c914e7a36033d5e8d52cdef3a4063eb9b012ed2)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
| |
|
|
|
|
|
|
| |
This reverts commit 3c73cf5 (gh-133497), which itself reverted
the original commit d270bb5 (gh-133221).
We reverted the original change due to failing android tests.
The checks in _PyCode_CheckNoInternalState() were too strict,
so we've relaxed them.
|
| |
|
|
| |
BINARY_OP/SUBSCR, apply to arrays (#133396)" (#133498)
|
| |
|
|
| |
(#133497)
|
| |
|
|
|
|
|
|
| |
"Stateless" code is a function or code object which does not rely on external state or internal state.
It may rely on arguments and builtins, but not globals or a closure. I've left a comment in
pycore_code.h that provides more detail.
We also add _PyFunction_VerifyStateless(). The new functions will be used in several later changes
that facilitate "sharing" functions and code objects between interpreters.
|
| |
|
| |
Make sure trashcan pointer look mortal -- 32 bit
|
| |
|
|
|
|
| |
This reverts commit 811edcf (gh-133232), which itself reverted the original commit 811edcf (gh-133128).
We reverted the original change due to failing s390 builds (a big-endian architecture).
It ended up that I had not accommodated op caches.
|
| |
|
|
| |
(#133144)
|
| |
|
|
| |
apply to arrays (#133396)
|
| |
|
|
|
|
|
|
| |
(#133199)" (#133434)
This reverts commit 662dd294563ce86980c640ad67e3d460a72c9cb9.
The root issue was fixed by the
commit f554237b8ef6c60df651ac17eb0ef0c095cef185.
|
| | |
|
| |
|
| |
Co-authored-by: sobolevn <mail@sobolevn.me>
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-133085)
Add `_Py_ALIGN_AS` as per C API WG vote: https://github.com/capi-workgroup/decisions/issues/61
This patch only adds it to free-threaded builds; the `#ifdef Py_GIL_DISABLED`
can be removed in the future.
Use this to revert `PyASCIIObject` memory layout for non-free-threaded builds.
The long-term plan is to deprecate the entire struct; until that happens
it's better to keep it unchanged, as courtesy to people that rely on it despite
it not being stable ABI.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
After gh-130704, the interpreter replaces some uses of `LOAD_FAST` with
`LOAD_FAST_BORROW` which avoid incref/decrefs by "borrowing" references
on the interpreter stack when the bytecode compiler can determine that
it's safe.
This change broke some checks in C API extensions that relied on
`Py_REFCNT()` of `1` to determine if it's safe to modify an object
in-place. Objects may have a reference count of one, but still be
referenced further up the interpreter stack due to borrowing of
references.
This provides a replacement function for those checks.
`PyUnstable_Object_IsUniqueReferencedTemporary` is more conservative:
it checks that the object has a reference count of one and that it exists as a
unique strong reference in the interpreter's stack of temporary
variables in the top most frame.
See also:
* https://github.com/numpy/numpy/issues/28681
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: mpage <mpage@cs.stanford.edu>
Co-authored-by: Mark Shannon <mark@hotpy.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
|
| |
|
|
|
|
| |
* Skip sNaN's testing in 32-bit mode.
* Drop float_set_snan() helper.
* Use memcpy() workaround for sNaN's in PyFloat_Unpack4().
* Document, that sNaN's may not be preserved by PyFloat_Pack/Unpack API.
|
| | |
|