]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-140061: Use `_PyObject_IsUniquelyReferenced()` to check if objects are...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 15 Oct 2025 14:49:17 +0000 (16:49 +0200)
committerGitHub <noreply@github.com>
Wed, 15 Oct 2025 14:49:17 +0000 (14:49 +0000)
commit045e34964a37ac50eecde481f93deedc640884da
tree05a58290a13e86d1c4f395be8d53105ca323d9f8
parent6b94c7ceebc7570d95cc68713fd3d62e5bb25391
[3.14] gh-140061: Use `_PyObject_IsUniquelyReferenced()` to check if objects are uniquely referenced (gh-140062) (gh-140157)

The previous `Py_REFCNT(x) == 1` checks can have data races in the free
threaded build. `_PyObject_IsUniquelyReferenced(x)` is a more conservative
check that is safe in the free threaded build and is identical to
`Py_REFCNT(x) == 1` in the default GIL-enabled build.
(cherry picked from commit 32c264982ec67460642b907dabc3304019318291)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-00-21-40.gh-issue-140061.J0XeDV.rst [new file with mode: 0644]
Modules/_elementtree.c
Modules/_functoolsmodule.c
Modules/itertoolsmodule.c
Objects/bytesobject.c
Objects/dictobject.c
Objects/longobject.c
Objects/setobject.c
Objects/tupleobject.c
Python/marshal.c