This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Created on 2008-01-23 18:34 by jforan, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg61597 - (view) Author: Jeff Foran (jforan) Date: 2008-01-23 18:34
Not sure where to put example code, but here it goes: import weakref class MyObj(object):	def __init__(self):	self.ref = weakref.ref(self)	def __del__(self):	print "HERE123", self.ref() o = MyObj() o = None
msg61600 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-01-23 20:21
The behavior is documented in the C code. I don't know how it is described in the docs. Objects/typeobject.c around line 820 says: /* If we added a weaklist, we clear it. Do this *before* calling the finalizer (__del__), clearing slots, or clearing the instance dict. */
msg61604 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-01-23 20:56
Georg, can you update the docs? Weak references *to* an object are cleared before the object's __del__ is called, to ensure that the weak reference callback (if any) finds the object healthy.
msg64317 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-03-22 10:07
Done in r61733.
History
Date User Action Args
2022-04-11 14:56:30adminsetgithub: 46213
2008-03-22 10:07:41georg.brandlsetstatus: open -> closed
messages: + msg64317
2008-01-23 20:56:28gvanrossumsetstatus: pending -> open
assignee: georg.brandl
messages: + msg61604
nosy: + gvanrossum, georg.brandl
versions: + Python 2.6, Python 3.0
2008-01-23 20:21:37christian.heimessetstatus: open -> pending
priority: normal
resolution: wont fix
messages: + msg61600
nosy: + christian.heimes
2008-01-23 18:34:14jforancreate