Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Include/internal/pycore_weakref.h
Co-authored-by: Sam Gross <colesbury@gmail.com>
  • Loading branch information
corona10 and colesbury authored Jan 3, 2024
commit 1662b5d03ea087afd4143db015f5b09a1190799e
10 changes: 2 additions & 8 deletions Include/internal/pycore_weakref.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ static inline int _is_dead(PyObject *obj)
// be able to "see" the target object even though it is supposed to be
// unreachable. See issue gh-60806.
#if defined(Py_GIL_DISABLED)
Py_ssize_t refcount = Py_REFCNT(obj);
if (refcount == 0) {
// In freethreading CPython, Py_REFCNT is only estimated count,
// so need to check shared refcount value too.
Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&obj->ob_ref_shared);
return _Py_REF_IS_MERGED(shared);
}
return 0;
Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&obj->ob_ref_shared);
return shared == _Py_REF_SHARED(0, _Py_REF_MERGED);
#else
return (Py_REFCNT(obj) == 0);
#endif
Expand Down