diff Objects/weakrefobject.c @ 80762:7e771f0363e2 2.7

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.
author Antoine Pitrou <solipsis@pitrou.net>
date Sat, 08 Dec 2012 21:15:26 +0100
parents 13b74c0b040c
children 59acde449f8d
line wrap: on
line diff
--- a/Objects/weakrefobject.c	Sat Dec 08 18:01:27 2012 +0200
+++ b/Objects/weakrefobject.c	Sat Dec 08 21:15:26 2012 +0100
@@ -52,9 +52,8 @@
 {
     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)