mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
SF patch 530070: pydoc regression, from Martin and Guido.
Change the way __doc__ is handled, to avoid blowing up on non-string __doc__ values.
This commit is contained in:
parent
587c98c863
commit
2400831773
2 changed files with 30 additions and 5 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue