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.

Title: Weak references and bound functions interact in a bad way
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
Status: closed Resolution: not a bug
Dependencies: Superseder: Instance methods and WeakRefs don't mix.
View: 14631
Assigned To: Nosy List: doko, loewis
Priority: normal Keywords:

Created on 2003-09-26 21:20 by doko, last changed 2022-04-10 16:11 by admin. This issue is now closed.

Messages (2)
msg18393 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2003-09-26 21:20
[forwarded from]

>>> import weakref
>>> class Foo:
...     def bar(self):
...             print 'Hello'
>>> x=Foo()
>>> y=weakref.ref(
>>> y
<weakref at 0x4021cb94; dead>

  This behavior is self-evidently wrong, and seems to
be due to an
implementation detail of Python.  There is a workaround
available here:
(I haven't
examined it closely, but it looks like it should work)
 Nevertheless, this
should be fixed eventually IMO.

msg18394 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-09-27 07:50
Logged In: YES 

I fail to see a bug here. creates a new object (a
bound method),
for which then a weak reference is created. Since there is
no strong
reference to the same bound method, the bound method is
deleted, and
the weak reference dies.
Date User Action Args
2022-04-10 16:11:24adminsetgithub: 39311
2012-11-26 17:44:33jceasetsuperseder: Instance methods and WeakRefs don't mix.
2003-09-26 21:20:11dokocreate