[Python-bugs-list] [ python-Bugs-548845 ] pydoc doesn't show C types

noreply@sourceforge.net noreply@sourceforge.net
Fri, 26 Apr 2002 10:19:22 -0700


Bugs item #548845, was opened at 2002-04-26 00:58
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=548845&group_id=5470

Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Greg Chapman (glchapman)
Assigned to: Nobody/Anonymous (nobody)
Summary: pydoc doesn't show C types

Initial Comment:
If you define a type in C and add it to a module's 
dictionary, it will not be displayed by pydoc.  Now 
that calling such types can serve as the constructor 
for the type's instances, I think pydoc should ensure 
that the types are displayed.

Pydoc sees such types as classes because 
inspect.isclass returns true for them:

def isclass(object):
    return isinstance(object, types.ClassType) or  
        hasattr(object, '__bases__')

(The above succeeds for because C types have a 
__bases__ attribute).  However, when pydoc checks to 
see if the type/class is defined in the module being 
documented, it uses the type's __module__ attribute to 
look up the module in sys.modules.  By default, C 
types always return "__builtin__" as their __module__, 
so pydoc concludes the type was actually declared in 
the __builtin__ module and does not show it.

(Perhaps this is really a documentation bug -- there 
does not seem to be anything indicating that types 
which wish to expose themselves to pydoc should 
redefine the __module__ attribute.)


----------------------------------------------------------------------

>Comment By: Thomas Heller (theller)
Date: 2002-04-26 19:19

Message:
Logged In: YES 
user_id=11105

As the most recent documentation (which is just a few days 
old) shows, it's a bug in the extensions module IMO ;-).
You have to use "<module>.<name>" as the tp_name slot in 
the extension type, and __module__ will automatically be 
set. pydoc then also documents this type.

http://starship.python.net/crew/theller/pyhelp.cgi?
keyword=tp_name&version=devel

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=548845&group_id=5470