diff options
author | Christian Tismer <tismer@stackless.com> | 2018-08-27 19:58:48 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2018-08-28 06:50:28 +0000 |
commit | ef2c47069c545f5afdf767c70add543bac4c77e6 (patch) | |
tree | 54b45f38f0690d910709a888f72234053f424cbe /sources | |
parent | a697423e4b5b37572a8a06a8904fc03b44d99f39 (diff) |
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 <cristian.maureira-fredes@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/pyside2/PySide2/support/signature/backport_inspect.py | 4 | ||||
-rw-r--r-- | sources/pyside2/PySide2/support/signature/loader.py | 5 |
2 files changed, 9 insertions, 0 deletions
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) |