[issue14933] Misleading documentation about weakrefs
report at bugs.python.org
Mon May 28 15:17:39 CEST 2012
New submission from Antoine Pitrou <pitrou at free.fr>:
In http://docs.python.org/dev/extending/newtypes.html?highlight=pyobject_clearweakrefs#weak-reference-support, you can read:
“The only further addition is that the destructor needs to call the weak reference manager to clear any weak references. This should be done before any other parts of the destruction have occurred”
I don't believe there is any need to clear weakrefs before starting with other parts of the destruction. Weakref callbacks cannot access the original object, by construction (else they never get called).
Actually, if a weakref callback can rely on some resources having been released (say, a file descriptor), it is better to clear the weakrefs *after* other parts of the destruction.
This seems to be a by-product of the erroneous doc committed in SVN r16381, part of which was removed in r18223.
assignee: docs at python
nosy: docs at python, fdrake, ncoghlan, pitrou, sbt, tim_one
title: Misleading documentation about weakrefs
versions: Python 2.7, Python 3.2, Python 3.3
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list