Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2e2dbe

Browse files
committed
Improve handling of docstrings. I had feared this was a case of
introspection incompatibility, but in fact it's just that calltips always gave up on a docstring that started with a newline (but didn't realize they were giving up <wink>).
1 parent 5b7759f commit a2e2dbe

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

Tools/idle/CallTips.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,16 @@ def get_arg_text(ob):
143143
except:
144144
pass
145145
# See if we can use the docstring
146-
if hasattr(ob, "__doc__") and ob.__doc__:
147-
pos = string.find(ob.__doc__, "\n")
148-
if pos<0 or pos>70: pos=70
149-
if argText: argText = argText + "\n"
150-
argText = argText + ob.__doc__[:pos]
146+
doc = getattr(ob, "__doc__", "")
147+
if doc:
148+
while doc[:1] in " \t\n":
149+
doc = doc[1:]
150+
pos = doc.find("\n")
151+
if pos < 0 or pos > 70:
152+
pos = 70
153+
if argText:
154+
argText += "\n"
155+
argText += doc[:pos]
151156

152157
return argText
153158

0 commit comments

Comments
 (0)