[issue19047] Assorted weakref docs improvements

Nick Coghlan report at bugs.python.org
Thu Sep 19 10:25:12 CEST 2013


Nick Coghlan added the comment:

Changing the title, since I spotted a few other problems as well.

The weakref docs still refer to module globals being set to None during shutdown. That is no longer the case. There are also some assumptions about cycles with __del__ methods not being garbage collected, which is no longer true given PEP 442's improvements to module finalization.

I also realised that the introduction of weakref.finalize and the elimination of the "set globals to None" hack gives Python relatively straightforward module destructors [1]:

    import weakref, sys
    mod = sys.modules[__name__]
    def del_this():
        # implicit ref to the module globals from the function body
    weakref.finalize(mod, del_this)

[1] https://mail.python.org/pipermail/import-sig/2013-September/000748.html

----------
title: Clarify weakref.finalize objects are kept alive automatically -> Assorted weakref docs improvements

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19047>
_______________________________________


More information about the Python-bugs-list mailing list