diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2020-11-20 01:59:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-20 01:59:11 -0500 |
commit | 7ddbaa7a1b3e61847ee99658be6a7268a049e302 (patch) | |
tree | 4e4a1aa9c86eeef83e11d18a81dbb8663142661e /Lib/idlelib/calltip.py | |
parent | e1dc0db8c7cb8c4d7343e051ba85146b375bb8e0 (diff) | |
download | cpython-7ddbaa7a1b3e61847ee99658be6a7268a049e302.tar.gz cpython-7ddbaa7a1b3e61847ee99658be6a7268a049e302.zip |
bpo-42416: Use inspect.getdoc for IDLE calltips (GH-23416)
Inspect.getdoc(ob) sometimes gets docstrings when ob.__doc__ is None.
Diffstat (limited to 'Lib/idlelib/calltip.py')
-rw-r--r-- | Lib/idlelib/calltip.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Lib/idlelib/calltip.py b/Lib/idlelib/calltip.py index 549e224015c..40bc5a0ad79 100644 --- a/Lib/idlelib/calltip.py +++ b/Lib/idlelib/calltip.py @@ -165,6 +165,7 @@ def get_argspec(ob): ob_call = ob.__call__ except BaseException: # Buggy user object could raise anything. return '' # No popup for non-callables. + # For Get_argspecTest.test_buggy_getattr_class, CallA() & CallB(). fob = ob_call if isinstance(ob_call, types.MethodType) else ob # Initialize argspec and wrap it to get lines. @@ -185,10 +186,7 @@ def get_argspec(ob): if len(argspec) > _MAX_COLS else [argspec] if argspec else []) # Augment lines from docstring, if any, and join to get argspec. - if isinstance(ob_call, types.MethodType): - doc = ob_call.__doc__ - else: - doc = getattr(ob, "__doc__", "") + doc = inspect.getdoc(ob) if doc: for line in doc.split('\n', _MAX_LINES)[:_MAX_LINES]: line = line.strip() |