diff options
author | Sam Gross <colesbury@gmail.com> | 2025-05-02 13:24:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-02 13:24:57 (GMT) |
commit | f2379535fe2d2219b71653782d5e31defd9b5556 (patch) | |
tree | 97fd405ea675fb919cc95f45e8467d954cedabc9 /Lib/test/test_pyrepl/test_unix_console.py | |
parent | 4701ff92d747002d04b67688c7a581b1952773ac (diff) | |
download | cpython-f2379535fe2d2219b71653782d5e31defd9b5556.zip cpython-f2379535fe2d2219b71653782d5e31defd9b5556.tar.gz cpython-f2379535fe2d2219b71653782d5e31defd9b5556.tar.bz2 |
gh-133164: Add `PyUnstable_Object_IsUniqueReferencedTemporary` C API (gh-133170)
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>
Diffstat (limited to 'Lib/test/test_pyrepl/test_unix_console.py')
0 files changed, 0 insertions, 0 deletions