[Python-Dev] results of id() and weakref.getweakrefs() sometimes break on object resurrection

Antoine Pitrou solipsis at pitrou.net
Sun Oct 26 01:22:58 CEST 2014


Hello Stefan,

On Sun, 26 Oct 2014 00:20:47 +0200
"Stefan Richthofer" <Stefan.Richthofer at gmx.de> wrote:
> Hello developers,
> 
> I observed strange behaviour in CPython (tested in 2.7.5 and 3.3.3)
> regarding object resurrection.

Your runGC() function is buggy, it does not run the GC under CPython.
Fix it and the first problem (with id()) disappears.

The second problem (with weakref) is different: weakrefs are cleared
before __del__ is called, so resurrection doesn't affect the whole
process. Add a callback to the weakref and you'll see it is getting
called.

In other words, CPython behaves as expected. Your concern is
appreciated, though.

Regards

Antoine.




More information about the Python-Dev mailing list