Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

charris
Copy link
Member

@charris charris commented Sep 5, 2025

Backport of #29649.

Checking Py_REFCNT == 1 is thread-unsafe on the free-threaded build, since refcounts are stored and loaded in free-threading using atomic operations.

Python 3.14 added PyUnstable_Object_IsUniquelyReferenced to replace static refcount checks. I added a backport to pythoncapi-compat in python/pythoncapi-compat#149, which allows me to use the function unconditionally and get correct behavior on 3.13t as well. This relies on some private implementation details on 3.13t, but all that is done in the compat header.

@charris charris added this to the 2.3.3 release milestone Sep 5, 2025
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs 39 - free-threading PRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703) labels Sep 5, 2025
@charris charris merged commit fea7e59 into numpy:maintenance/2.3.x Sep 5, 2025
75 checks passed
@charris charris deleted the backport-29649 branch September 5, 2025 17:55
hswong3i added a commit to alvistack/numpy-numpy that referenced this pull request Sep 10, 2025
    git clean -xdf
    git submodule sync --recursive
    git submodule update --recursive --init
    git submodule foreach --recursive git checkout -- .
    tar zcvf ../python-numpy_2.3.3.orig.tar.gz --exclude=.git .
    debuild -uc -us
    cp python-numpy.spec ../python-numpy_2.3.3-1.spec
    cp ../python*-numpy*2.3.3*.{gz,xz,spec,dsc} /osc/home\:alvistack/numpy-numpy-2.3.3/
    rm -rf ../python*-numpy*2.3.3*.*

See numpy#27405
See numpy#29685

Signed-off-by: Wong Hoi Sing Edison <[email protected]>
hswong3i added a commit to alvistack/numpy-numpy that referenced this pull request Sep 10, 2025
    git clean -xdf
    git submodule sync --recursive
    git submodule update --recursive --init
    git submodule foreach --recursive git checkout -- .
    tar zcvf ../python-numpy_2.3.3.orig.tar.gz --exclude=.git .
    debuild -uc -us
    cp python-numpy.spec ../python-numpy_2.3.3-1.spec
    cp ../python*-numpy*2.3.3*.{gz,xz,spec,dsc} /osc/home\:alvistack/numpy-numpy-2.3.3/
    rm -rf ../python*-numpy*2.3.3*.*

See numpy#27405
See numpy#29685

Signed-off-by: Wong Hoi Sing Edison <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 08 - Backport Used to tag backport PRs 39 - free-threading PRs and issues related to support for free-threading CPython (a.k.a. no-GIL, PEP 703)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants