[issue40312] Weakref callbacks running before finalizers in GC collection

Pablo Galindo Salgado report at bugs.python.org
Mon Apr 20 13:03:35 EDT 2020


Pablo Galindo Salgado <pablogsal at gmail.com> added the comment:

> Pablo, as above, I'm inclined to leave things alone unless we can "prove" no current code could possibly be relying (even by accident) on that gc currently runs callbacks before finalizers.  Which may be the case!  I don't know ;-)

I very much agree with this. Also, (I think you already mentioned this) over-specifying the order of things in the gc may be a great way to shoot ourselves in the foot if we need to fix bugs or some odd behaviour during finalization/destruction (think for instance the latest bug regarding tp_clear and weakref callbacks).

I think we could at least improve somehow the docs, to say at least that the order is not specified so people that look at them do not rely on it.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40312>
_______________________________________


More information about the Python-bugs-list mailing list