On 13 Oct 2013 08:27, "Ethan Furman" <et...@stoneleaf.us> wrote: > > It was pointed in Issue16938[1] that __objclass__ is not documented anywhere. > > Is the following an appropriate description? (in Doc/reference/datamodel.rst > in user-defined functions) > > > > +-------------------------+-------------------------------+-----------+ > | :attr:`__objclass__` | The class this object belongs | | > | | to; useful when the object is | | > | | a descriptor, or a virtual or | | > | | dynamic class attribute, and | | > | | it's __class__ attribute does | | > | | not match the class it is | | > | | associated with, or it is not | | > | | in that class' ``__dict__``. | | > +-------------------------+-------------------------------+-----------+
I think this is inaccurate. The meaning of __objclass__ as described in PEP 252 is to denote unbound callable descriptors that only work with a specific type. That's why it's mostly gone in Python 3. It should be documented, but the documentation should say something like: __objclass__: Indicates this callable requires an instance of the given type (or a subclass) as its first positional argument. For example, CPython sets this for unbound methods that are implemented in C rather than Python. The offending block of code in the inspect module (http://hg.python.org/cpython/file/default/Lib/inspect.py#l366) that prompted http://bugs.python.org/issue16938 just looks flat out broken to me. There's *zero* reason to expect that __class__ on the result of retrieving an attribute from an object will appear in the MRO for that object. I just missed that detail when reviewing http://bugs.python.org/issue19030 :) I'll reply on the tracker with some additional details/suggestions. Cheers, Nick. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com