Nick Coghlan added the comment:

Yeah, I've figured out that rather than exposing __del__ if tp_del is 
populated, or generalising the generator special case, the simplest way to make 
this info accessible is to be able to ask the *garbage collector* if it thinks 
an object needs finalising.

That actually makes this a pretty easy issue (as C issues go) - it's just a 
matter of exposing 
http://hg.python.org/cpython/file/default/Modules/gcmodule.c#l525 
(has_finalizer) as gc.needs_finalizing.

It will be easier once #17468 is done though, since that will make it clearer 
what the documentation should say.

----------
dependencies: +Generator memory leak
keywords: +easy
title: Expose __del__ when tp_del is populated from C code -> Add 
gc.needs_finalizing() to check if an object needs finalising

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17800>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to