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 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 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. |
|||
| msg18394 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2003年09月27日 07:50 | |
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. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月10日 16:11:24 | admin | set | github: 39311 |
| 2012年11月26日 17:44:33 | jcea | set | superseder: Instance methods and WeakRefs don't mix. |
| 2003年09月26日 21:20:11 | doko | create | |