[docs] [issue15412] Note in documentation for weakrefs

Richard Oudkerk report at bugs.python.org
Sat Jul 21 11:41:58 CEST 2012

New submission from Richard Oudkerk <shibturn at gmail.com>:

In the documentation on weakrefs there is the following quote

    Note: Weak references to an object are cleared before the object’s
    __del__() is called, to ensure that the weak reference callback 
    (if any) finds the object still alive.

But I think the weakref is always dead by the time the callback is invoked.  The first paragraph from the documentation for weakref.ref(object[, callback]) contains the following:

    If callback is provided and not None, and the returned weakref 
    object is still alive, the callback will be called when the object 
    is about to be finalized; the weak reference object will be passed 
    as the only parameter to the callback; **the referent will no longer 
    be available**.

Which does prompt a question: what use is there for the weakref argument to the callback if it already dead?

(Compare http://bugs.python.org/issue14933)

assignee: docs at python
components: Documentation
messages: 166002
nosy: docs at python, pitrou, sbt
priority: normal
severity: normal
status: open
title: Note in documentation for weakrefs

Python tracker <report at bugs.python.org>

More information about the docs mailing list