[Python-Dev] issue 9141, finalizers and gc module

Kristján Valur Jónsson kristjan at ccpgames.com
Fri Apr 20 15:28:38 CEST 2012

> -----Original Message-----
> From: python-dev-bounces+kristjan=ccpgames.com at python.org
> [mailto:python-dev-bounces+kristjan=ccpgames.com at python.org] On
> Behalf Of martin at v.loewis.de
> Sent: 18. apríl 2012 07:11
> To: python-dev at python.org
> Subject: Re: [Python-Dev] issue 9141, finalizers and gc module
> Invoking methods in tp_clear I find fairly harmless, in comparison. My only
> concern is that errors are silently ignored. However, I don't think this matters
> in practice, since io objects typically are not part of cycles, anyway.
> > Why not allow it for all objects, then?
> It's *allowed* for all objects. Why do you think it is not?
Oh, because dynamic classes with __del__ methods are deliberately not collected but put in gc.garbage.  And the special case of the generator object, etc. etc.

iobase.c probably documents its own needs well enough.  The fact that I had to raise this question here, though, means that the source code  for gcmodule.c doesn't have enough information to explain exactly the problem that it has with calling finalizers.
It seems to me that it worries that __del__ methods may not run to completion because of attribute errors, and that it would have to silence such errors to not cause unexpected noise.
That is the impression I get from this discussion.  Correctness over memory conservation, or something like that.

Btw, regarding object resurrection, I was working on a patch to get that to work better, particularly with subclasses.
You may want to check out issue 8212, whence this discussion originates.


More information about the Python-Dev mailing list