mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #16602: When a weakref's target was part of a long deallocation chain, the object could remain reachable through its weakref even though its refcount had dropped to zero.
Thanks to Eugene Toder for diagnosing and reporting the issue.
This commit is contained in:
parent
09974b4e9e
commit
62a0d6ea40
5 changed files with 39 additions and 4 deletions
|
@ -52,9 +52,8 @@ clear_weakref(PyWeakReference *self)
|
|||
{
|
||||
PyObject *callback = self->wr_callback;
|
||||
|
||||
if (PyWeakref_GET_OBJECT(self) != Py_None) {
|
||||
PyWeakReference **list = GET_WEAKREFS_LISTPTR(
|
||||
PyWeakref_GET_OBJECT(self));
|
||||
if (self->wr_object != Py_None) {
|
||||
PyWeakReference **list = GET_WEAKREFS_LISTPTR(self->wr_object);
|
||||
|
||||
if (*list == self)
|
||||
/* If 'self' is the end of the list (and thus self->wr_next == NULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue