summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2003-06-11 23:38:55 (GMT)
committerBrett Cannon <bcannon@gmail.com>2003-06-11 23:38:55 (GMT)
commit28a4f0f9659e6f64eee8905b21953e7ba6ff68fa (patch)
tree0c267d3bab7eadc5a3c1f8db9845c4532be2db8a /Lib
parent10147f7d1321441e46463fd8aa18bc2dd0be6c2d (diff)
downloadcpython-28a4f0f9659e6f64eee8905b21953e7ba6ff68fa.zip
cpython-28a4f0f9659e6f64eee8905b21953e7ba6ff68fa.tar.gz
cpython-28a4f0f9659e6f64eee8905b21953e7ba6ff68fa.tar.bz2
Have pydoc try handling an object as "other" if the object does not act the way
it expects based on what inspect classifies it as. Closes bug #729103 .
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/pydoc.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index a6778d6..fe114fd 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -275,9 +275,16 @@ class Doc:
def document(self, object, name=None, *args):
"""Generate documentation for an object."""
args = (object, name) + args
- if inspect.ismodule(object): return self.docmodule(*args)
- if inspect.isclass(object): return self.docclass(*args)
- if inspect.isroutine(object): return self.docroutine(*args)
+ # 'try' clause is to attempt to handle the possibility that inspect
+ # identifies something in a way that pydoc itself has issues handling;
+ # think 'super' and how it is a descriptor (which raises the exception
+ # by lacking a __name__ attribute) and an instance.
+ try:
+ if inspect.ismodule(object): return self.docmodule(*args)
+ if inspect.isclass(object): return self.docclass(*args)
+ if inspect.isroutine(object): return self.docroutine(*args)
+ except AttributeError:
+ pass
return self.docother(*args)
def fail(self, object, name=None, *args):