2012/10/14 Stefan Behnel <stefan...@behnel.de>:
> Hi,
>
> when creating a new weakref using PyWeakref_NewRef(obj, callback), a Python
> callback function can be registered that is supposed to get called when the
> weakly referenced object dies. The callback receives a single argument, the
> weakref object.
>
> Now, the weak reference object itself is mostly useless, what is
> interesting is the object it originally referenced. I tried getting at that
> object by calling PyWeakref_LockObject(), but that already returns None at
> that point. PyWeakref_GetObject() is basically just a wrapper around that
> function and behaves the same.
>
> Is there any way to figure out what that object was that has just died when
> the callback gets called?

I don't think so:
http://docs.python.org/library/weakref.html#weakref.ref
"""the weak reference object will be passed as the only parameter to
the callback; the referent will no longer be available."""


-- 
Amaury Forgeot d'Arc
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to