summaryrefslogtreecommitdiff
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-03-17 18:56:20 +0000
committerTim Peters <tim.peters@gmail.com>2002-03-17 18:56:20 +0000
commit240083177368a929a4ab15098a94b0a6f71aeeed (patch)
tree60ae0540ceecc80af74467cfa545c8b8ebda7f49 /Lib/inspect.py
parent587c98c863ca11d779a63f559d435c4c8f30eb93 (diff)
downloadcpython-git-240083177368a929a4ab15098a94b0a6f71aeeed.tar.gz
SF patch 530070: pydoc regression, from Martin and Guido.
Change the way __doc__ is handled, to avoid blowing up on non-string __doc__ values.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 806f526690..9e2d23d58b 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -263,8 +263,17 @@ def getdoc(object):
All tabs are expanded to spaces. To clean up docstrings that are
indented to line up with blocks of code, any whitespace than can be
uniformly removed from the second line onwards is removed."""
- if hasattr(object, '__doc__') and object.__doc__:
- lines = string.split(string.expandtabs(object.__doc__), '\n')
+ try:
+ doc = object.__doc__
+ except AttributeError:
+ return None
+ if not isinstance(doc, (str, unicode)):
+ return None
+ try:
+ lines = string.split(string.expandtabs(doc), '\n')
+ except UnicodeError:
+ return None
+ else:
margin = None
for line in lines[1:]:
content = len(string.lstrip(line))