]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-140061: Use `_PyObject_IsUniquelyReferenced()` to check if objects are uniquely...
authorSergey Miryanov <sergey.miryanov@gmail.com>
Wed, 15 Oct 2025 13:48:21 +0000 (18:48 +0500)
committerGitHub <noreply@github.com>
Wed, 15 Oct 2025 13:48:21 +0000 (09:48 -0400)
commit32c264982ec67460642b907dabc3304019318291
tree27c1b9c67318187e591df9f4358794ff47716e98
parentfe9ac7fc8ca00515b3c9a4d91d7bbfe038c861e7
gh-140061: Use `_PyObject_IsUniquelyReferenced()` to check if objects are uniquely referenced (gh-140062)

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.
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