From 7ddbaa7a1b3e61847ee99658be6a7268a049e302 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Fri, 20 Nov 2020 01:59:11 -0500 Subject: bpo-42416: Use inspect.getdoc for IDLE calltips (GH-23416) Inspect.getdoc(ob) sometimes gets docstrings when ob.__doc__ is None. --- Lib/idlelib/calltip.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Lib/idlelib/calltip.py') diff --git a/Lib/idlelib/calltip.py b/Lib/idlelib/calltip.py index 549e224015..40bc5a0ad7 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() -- cgit v1.2.1