[New-bugs-announce] [issue14933] Misleading documentation about weakrefs

Antoine Pitrou 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
components: Documentation
messages: 161780
nosy: docs at python, fdrake, ncoghlan, pitrou, sbt, tim_one
priority: normal
severity: normal
status: open
title: Misleading documentation about weakrefs
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3

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


More information about the New-bugs-announce mailing list