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.

Author MHOOO
Recipients MHOOO
Date 2007-11-10.12:20:51
SpamBayes Score 0.17294462
Marked as misclassified No
Message-id <1194697252.02.0.163162643165.issue1417@psf.upfronthosting.co.za>
In-reply-to
Content
The following code is not working as expected:
import weakref
class cls1:
	def giveTo( self, to ):
		to.take( self.bla )
	def bla(self ):
		pass
		
class cls2:
	def take( self, what ):
		self.ref = weakref.ref(what)
		
c1 = cls1()
c2 = cls2()
c1.giveTo( c2 )
print c1.bla
print c2.ref

It prints out:
<bound method cls1.bla of <__main__.cls1 instance at 0x00CA9E18>>
<weakref at 00CAF180; dead>

Why is the weakref pointing to a dead object, when it's still alive?
Files
File name Uploaded
test2.py MHOOO, 2007-11-10.12:20:51
History
Date User Action Args
2007-11-10 12:20:52MHOOOsetspambayes_score: 0.172945 -> 0.17294462
recipients: + MHOOO
2007-11-10 12:20:52MHOOOsetspambayes_score: 0.172945 -> 0.172945
messageid: <1194697252.02.0.163162643165.issue1417@psf.upfronthosting.co.za>
2007-11-10 12:20:51MHOOOlinkissue1417 messages
2007-11-10 12:20:51MHOOOcreate