[Epydoc-commits] SF.net SVN: epydoc: [1327] trunk/epydoc/src/epydoc/docintrospecter.py
Brought to you by:
edloper
From: <ed...@us...> - 2006-08-29 20:32:29
|
Revision: 1327 Author: edloper Date: 2006-08-29 13:32:24 -0700 (Tue, 29 Aug 2006) ViewCVS: http://svn.sourceforge.net/epydoc/?rev=1327&view=rev Log Message: ----------- Fixed SF bug [ 1546630 ] epydoc chokes on wicked tuple subclass, which was caused because inspect.isclass() returned true for *any* object that appeared to have a __bases__ attribute; including objects that just override __getattr__ to always return a value. The fix replaces inspect.isclass() with a new isclass(obj) function that just checks if isinstance(obj, (TypeType,ClassType)). Hopefully this won't break introspection for any magic class-like objects people are using. Modified Paths: -------------- trunk/epydoc/src/epydoc/docintrospecter.py Modified: trunk/epydoc/src/epydoc/docintrospecter.py =================================================================== --- trunk/epydoc/src/epydoc/docintrospecter.py 2006-08-25 07:55:50 UTC (rev 1326) +++ trunk/epydoc/src/epydoc/docintrospecter.py 2006-08-29 20:32:24 UTC (rev 1327) @@ -504,6 +504,18 @@ # Helper functions #//////////////////////////////////////////////////////////// +def isclass(object): + """ + Return true if the given object is a class. In particular, return + true if object is an instance of C{types.TypeType} or of + C{types.ClassType}. This is used instead of C{inspect.isclass()}, + because the latter returns true for objects that are not classes + (in particular, it returns true for any object that has a + C{__bases__} attribute, including objects that define + C{__getattr__} to always return a value). + """ + return isinstance(object, (TypeType, ClassType)) + def get_docstring(value): """ Return the docstring for the given value; or C{None} if it @@ -623,7 +635,7 @@ """ if inspect.ismodule(value): return DottedName(value.__name__) - elif inspect.isclass(value): + elif isclass(value): return DottedName(value.__module__) elif (inspect.ismethod(value) and value.im_self is not None and value.im_class is ClassType): # class method. @@ -702,7 +714,7 @@ def is_staticmethod(v): return isinstance(v, staticmethod) def is_property(v): return isinstance(v, property) register_introspecter(inspect.ismodule, introspect_module, priority=20) -register_introspecter(inspect.isclass, introspect_class, priority=24) +register_introspecter(isclass, introspect_class, priority=24) register_introspecter(inspect.isroutine, introspect_routine, priority=28) register_introspecter(is_property, introspect_property, priority=30) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |