[issue42671] Make the Python finalization more deterministic

STINNER Victor report at bugs.python.org
Fri Dec 18 05:51:28 EST 2020


STINNER Victor <vstinner at python.org> added the comment:

> Drawback: it is a backward incompatible change. Code which worked by luck previously no longer works. I'm talking about applications which rely on __del__() methods being calling in an exact order and expect Python being in a specific state.

Python does not provide any warranty in which order finalizers are called:
https://docs.python.org/dev/reference/datamodel.html#object.__del__

PyPy is a good concrete example of finalizers being called in a different order.

An application must not rely on the finalizer order, but manage resources explicitly by calling close() methods or using context managers. Python emits ResourceWarning on this purpose.

----------

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


More information about the Python-bugs-list mailing list