[Python-bugs-list] [ python-Bugs-813299 ] Weak references and bound
functions interact in a bad way
SourceForge.net
noreply at sourceforge.net
Sat Sep 27 03:50:01 EDT 2003
Bugs item #813299, was opened at 2003-09-26 23:20
Message generated for change (Comment added) made by loewis
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=813299&group_id=5470
Category: Python Interpreter Core
Group: Python 2.3
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Matthias Klose (doko)
Assigned to: Nobody/Anonymous (nobody)
Summary: Weak references and bound functions interact in a bad way
Initial Comment:
[forwarded from http://bugs.debian.org/211129]
>>> import weakref
>>> class Foo:
... def bar(self):
... print 'Hello'
...
>>> x=Foo()
>>> y=weakref.ref(x.bar)
>>> 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:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81253
(I haven't
examined it closely, but it looks like it should work)
Nevertheless, this
should be fixed eventually IMO.
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2003-09-27 09:50
Message:
Logged In: YES
user_id=21627
I fail to see a bug here. x.bar 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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=813299&group_id=5470
More information about the Python-bugs-list
mailing list