[issue25435] Wrong function calls and referring to not removed concepts in descriptor HowTo (documentation)
New submission from David Becher: Since Python 3 removed unbound methods, I found some references using the old terminology in this HowTo about descriptors (https://docs.python.org/3/howto/descriptor.html). Also, since unbound methods have been removed, the function call types.MethodType now only takes two arguments, namely the function to bind and the object to bind to. In the current documentation, however, the old function call with three arguments is still being used. I made a pull request on github, then I realized that it is just a mirror repo. Attached you will see a patch file with some of the obvious changes that could me made to the document ---------- assignee: docs@python components: Documentation files: 21.diff.txt messages: 253159 nosy: David Becher, docs@python priority: normal severity: normal status: open title: Wrong function calls and referring to not removed concepts in descriptor HowTo (documentation) versions: Python 3.6 Added file: http://bugs.python.org/file40812/21.diff.txt _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Changes by SilentGhost <ghost.adh@gmail.com>: ---------- nosy: +rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Martin Panter added the comment: Thanks for the patch. I left a few comments on the code review. I think the class is meant to represent a real function object, not a wrapper. And it would be good to update the following paragraphs about unbound methods. Also, it looks like the rest of that page could do with some other updates. E.g. no need for explicit Function(object) base class, no need to mention that a method exists in Python 2.3, code could use @classmethod decorator syntax. But these are a slightly separate issues. ---------- nosy: +martin.panter stage: -> patch review versions: +Python 3.4, Python 3.5 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Martin Panter added the comment: Also further up the page, “unbound methods . . . are . . . based on the descriptor protocol” is probably not really correct or useful. Issue 23702 is already open about mentioning unbound methods. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Changes by Raymond Hettinger <raymond.hettinger@gmail.com>: ---------- assignee: docs@python -> rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Raymond Hettinger added the comment: I'll update this document to reflect the current state of the world. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Daniel Holth added the comment: This bit me also. Is there other documentation for how many arguments MethodType() should take? ---------- nosy: +dholth _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Eryk Sun added the comment: I'm surprised it's not documented for the types module: https://docs.python.org/3.5/library/types.html#types.MethodType At least the docstring has the parameters: >>> print(types.MethodType.__doc__) method(function, instance) Create a bound instance method object. ---------- nosy: +eryksun _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Changes by Mariatta Wijaya <mariatta.wijaya@gmail.com>: ---------- nosy: +Mariatta _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Martin Panter added the comment: Raymond I suggest you unassign this and let others work on it. ---------- stage: patch review -> needs patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Changes by Mariatta Wijaya <mariatta.wijaya@gmail.com>: ---------- versions: +Python 3.7 -Python 3.4 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Raymond Hettinger added the comment: I will have a chance to work on this before long. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Marco Buttu added the comment: I also noticed that the howto differentiates between objects and classes: "The details of invocation depend on whether obj is an object or a class." I think it is misleading, because a class is actually an object. IMHO is better to differentiate between classes and non-classes objects: "The details of invocation depend on whether obj is a class or not." ---------- nosy: +marco.buttu _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Raymond Hettinger added the comment:
I think it is misleading, because a class is actually an object.
This is only misleading *after* you know all the interesting details about Python and metaclasses. Prior to that, it is a reasonable and important distinction that I don't want to get lost in weasel words. The calls from object.__getattribute__ are different that those from type.__getattribute__. Likewise, data and non-data descriptors can only be described in terms of objects versus classes. Lastly, descriptors only work when stored in a class, if you store them in instances, they don't get invoked. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue25435> _______________________________________
Raymond Hettinger added the comment: I've just updated the section on unbound methods. I'll be working on a number of other improvements over the next few weeks and will incorporate the suggested changes where appropriate. ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue25435> _______________________________________
Raymond Hettinger <raymond.hettinger@gmail.com> added the comment: This was fixed a long time ago. ---------- resolution: -> out of date stage: needs patch -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue25435> _______________________________________
participants (8)
-
Daniel Holth
-
David Becher
-
Eryk Sun
-
Marco Buttu
-
Mariatta Wijaya
-
Martin Panter
-
Raymond Hettinger
-
SilentGhost