SIGN IN SIGN UP

[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>
M
Miss Islington (bot) committed
045e34964a37ac50eecde481f93deedc640884da
Parent: 6b94c7c
Committed by GitHub <noreply@github.com> on 10/15/2025, 2:49:17 PM