[issue19047] Assorted weakref docs improvements
Roundup Robot added the comment: New changeset caa16423b324 by Nick Coghlan in branch 'default': Close #19047: weakref doc cleanups http://hg.python.org/cpython/rev/caa16423b324 -- nosy: +python-dev resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19047 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19047] Assorted weakref docs improvements
Richard Oudkerk added the comment: Thanks for the doc cleanup -- I am rather busy right now. Note that stuff does still get replaced by None at shutdown, and this can still produce errors, even if they are much harder to trigger. If I run the following program import _weakref import collections a = hello class Foo(object): def __del__(self): print(a) collections.foo = Foo() _weakref.foo = Foo() then depending on the initial hashseed I get a reproducible error: $ PYTHONHASHSEED=7 python-release /tmp/bad.py Exception ignored in: bound method Foo.__del__ of __main__.Foo object at 0xb733db8c Traceback (most recent call last): File /tmp/bad.py, line 8, in __del__ TypeError: 'NoneType' object is not callable (Personally I would like to see a flag set late during shutdown which blocks __del__ methods from running.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19047 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19047] Assorted weakref docs improvements
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 rep...@bugs.python.org http://bugs.python.org/issue19047 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19047] Assorted weakref docs improvements
Antoine Pitrou added the comment: Doc patches certainly welcome :-) -- nosy: +pitrou, sbt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19047 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19047] Assorted weakref docs improvements
Nick Coghlan added the comment: I was initially thinking to myself I have a source checkout right here, I should just fix it, even though I'm at work and want to go home... and then I realised the potential scope of the fixes needed, given the longstanding misbehaviours these docs assume still exist :) (I also just realised the clone on my work system is ridiculously stale, so even updating it will likely take a while at this point) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19047 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com