New submission from Ronald Oussoren:

If a class implements __dir__ to also return a number of attributes that aren't 
present in the class __dict__ inspect.classify_class_attrs gets confused and 
assumes the home class is None.

This in turn confused pydoc, docclass in pydoc assumes that the 'class' slot in 
the sequence returned by classify_class_attrs is actually a class and fails 
when it None (because None doesn't have a __name__ attribute).

I've classified this as "low" because I've found a useable workaround: I have 
implemented a "__objclass__" property for my custom descriptor and with that 
pydoc works.

It would be nice if pydoc wouldn't crash on this. One possible workaround: 
assume that the class is the inspected class when a name returned by dir(cls) 
cannot be found in one of the classes on the mro.

I'll provide a patch if this would be acceptable behavior.

----------
components: Library (Lib)
messages: 179738
nosy: ronaldoussoren
priority: low
severity: normal
stage: test needed
status: open
title: pydoc confused by __dir__
type: behavior
versions: Python 2.7, Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16938>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to