[issue16938] pydoc confused by __dir__

Ethan Furman report at bugs.python.org
Sun Oct 13 16:45:13 CEST 2013


Ethan Furman added the comment:

'None' is not an appropriate response to the "Where does this attribute come from" question.  For one, it's wrong.  For two, it breaks help.

The current patch fixes that particular problem (as a last resort it walks the mro looking for the last class that reported having the attribute, and returns that class as the home class).

The reason it has the __class__, __objclass__ two-step in there was to handle cases like Enum members that do have __class__ set correctly and do not have __objclass__ set at all as it was falsely reporting the home class in that case as None.

Nick Coughlan said:
> The restriction that the __class__ of the object returned by a descriptor
> must appear in the MRO doesn't make any sense.

In the context of finding the home class it does:  if the __class__ returned by a descriptor is not in the mro then just like None it 1) is wrong (it doesn't reflect how it came it be in the class being looked up), and 2) it gives weird results in help.

The added tests in the patch may shed more light if my explanation isn't making sense.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16938>
_______________________________________


More information about the Python-bugs-list mailing list