From ef2c47069c545f5afdf767c70add543bac4c77e6 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Mon, 27 Aug 2018 19:58:48 +0200 Subject: Fix help display of backport_inspect (python 2.7) Python 2.7 has no signatures in its inspect module. We therefore add the missing stuff for the signature package using 'backport_inspect.py'. The resulting module is a bit unusual because it is assembled from different modules at runtime. When trying the code >>> from PySide2.support.signature import inspect >>> help(inspect) in Python2, we got only very little information because of some heuristics in the pydoc module that checks the module identity and finds only objects from the new one. It turned out that this heuristics can be circumvented when the "__all__" property is provided. pydoc then believes everything. We now have complete help info if the above module is used. The original inspect module is not changed at all. Change-Id: I3f24ada3b9ae9c79ec69a6280ddf3ea78735467b Reviewed-by: Cristian Maureira-Fredes Reviewed-by: Friedemann Kleint --- sources/pyside2/PySide2/support/signature/backport_inspect.py | 4 ++++ sources/pyside2/PySide2/support/signature/loader.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/sources/pyside2/PySide2/support/signature/backport_inspect.py b/sources/pyside2/PySide2/support/signature/backport_inspect.py index 9fed3e82e..0eafe9caa 100644 --- a/sources/pyside2/PySide2/support/signature/backport_inspect.py +++ b/sources/pyside2/PySide2/support/signature/backport_inspect.py @@ -88,6 +88,10 @@ PSF LICENSE AGREEMENT FOR PYTHON 3.7.0 to be bound by the terms and conditions of this License Agreement. """ +__doc__ = """ + signature() - get a Signature object for the callable +""" + import sys from collections import OrderedDict diff --git a/sources/pyside2/PySide2/support/signature/loader.py b/sources/pyside2/PySide2/support/signature/loader.py index 984e738df..f51bafe79 100644 --- a/sources/pyside2/PySide2/support/signature/loader.py +++ b/sources/pyside2/PySide2/support/signature/loader.py @@ -69,7 +69,12 @@ else: import inspect namespace = inspect.__dict__ from PySide2.support.signature import backport_inspect as inspect + _doc = inspect.__doc__ inspect.__dict__.update(namespace) + inspect.__doc__ += _doc + # force inspect to find all attributes. See "heuristic" in pydoc.py! + inspect.__all__ = list(x for x in dir(inspect) if not x.startswith("_")) + # name used in signature.cpp from PySide2.support.signature.parser import pyside_type_init sys.path.pop(0) -- cgit v1.2.3