[docs] [issue20751] Misleading examples indDescriptor protocol documentation
report at bugs.python.org
Sun Feb 23 23:13:56 CET 2014
New submission from Jan Kaliszewski:
1. One misleading detail in the descriptor protocol documentation for super bindings is that the following fragment of the http://docs.python.org/reference/datamodel.html#invoking-descriptors page:
If a is an instance of super, then the binding super(B, obj).m() searches obj.__class__.__mro__ for the base class A immediately preceding B and then invokes the descriptor with the call: A.__dict__['m'].__get__(obj, obj.__class__).
...introduces the method *call* (".m()") which AFAIK has nothing to do with the actual matter of the description (attribute resolution).
Also, the "If *a* is an instance of super" fragment is strange, as *a* is not used in the following sentences at all.
I believe the description should be:
If binding to a super instance, super(B, obj).x searches obj.__class__.__mro__ for the base class A immediately preceding B and then invokes the descriptor with the call: A.__dict__['x'].__get__(obj, obj.__class__).
(using 'x' as the attribute name, as for the other kinds of binding).
2. Also, in some earlier fragment of the same page:
The simplest and least common call is when user code directly invokes a descriptor method: x.__get__(a).
The call x.__get__(a) without the second argument seems to be wrong if __get__ is implemented according to the specification "object.__get__(self, instance, owner)" from the same documentation page.
assignee: docs at python
nosy: docs at python, zuo
title: Misleading examples indDescriptor protocol documentation
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4
Python tracker <report at bugs.python.org>
More information about the docs