classification
Title: Misleading descriptor protocol documentation: direct call, super binding
Type: Stage: needs patch
Components: Documentation Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: 12077 Superseder:
Assigned To: docs@python Nosy List: docs@python, martin.panter, rhettinger, zuo
Priority: normal Keywords:

Created on 2014-02-23 22:13 by zuo, last changed 2017-05-20 13:36 by BreamoreBoy.

Messages (3)
msg212035 - (view) Author: Jan Kaliszewski (zuo) Date: 2014-02-23 22:13
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:

"""
Super Binding
    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:

"""
Super Binding
    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:

"""
Direct Call
    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.
msg237709 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2015-03-09 21:37
Who is best placed to comment on the suggested docs changes given in msg212035?
msg294023 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-05-20 09:35
Lower-case “a” is defined at the top of the list: “The starting point . . . is ‘a.x’.” The last entry may fit in better if it was written “If binding to an instance of ‘super’ ”.

The problem with the m() call is also mentioned in Issue 25777, about the descriptor how-to.

Issue 12077 seems to be largely about the __get__ signature.
History
Date User Action Args
2017-05-20 13:36:56BreamoreBoysetnosy: - BreamoreBoy
2017-05-20 09:35:51martin.pantersetdependencies: + Harmonizing descriptor protocol documentation

title: Misleading examples in the descriptor protocol documentation -> Misleading descriptor protocol documentation: direct call, super binding
nosy: + rhettinger, martin.panter
versions: + Python 2.7, Python 3.6, Python 3.7, - Python 3.4
messages: + msg294023
stage: needs patch
2015-03-09 21:37:59BreamoreBoysetnosy: + BreamoreBoy

messages: + msg237709
versions: + Python 3.5, - Python 3.1, Python 2.7, Python 3.2, Python 3.3
2014-02-23 22:51:39zuosettitle: Misleading examples indDescriptor protocol documentation -> Misleading examples in the descriptor protocol documentation
2014-02-23 22:13:56zuocreate