diff options
| author | Christian Tismer <tismer@stackless.com> | 2022-11-14 18:24:23 +0100 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2022-11-15 11:54:36 +0100 |
| commit | 95e9f8fd675c6e4f1eeabe9337a7cb9c1e3b4456 (patch) | |
| tree | 87af9747e674832100af68fdcf91c3dbb76d39cb /sources/pyside6/PySide6/support/deprecated.py | |
| parent | 15436a08f9cde34f2594b192314ad842906f9ed1 (diff) | |
signature: Fix handling of rlcompleter as intermediate solution
The rlcompleter module calls inspect.signature which breaks
the multi-signatures of the signature C module.
The __signature__ attribute should no longer be used anyway
and people should use get_signature(), instead. But before we
evict this attribute, this patch fixes the problem, temporarily.
[ChangeLog][PySide6] Python 3.10 and up have an incompatibility
to the __signature__ attribute. This temporary patch fixes this
until final removal of that attribute.
Change-Id: Ic08d551cd388e6b3b29eb4694427a7202a4272b4
Fixes: PYSIDE-2101
Pick-to: 6.4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/PySide6/support/deprecated.py')
| -rw-r--r-- | sources/pyside6/PySide6/support/deprecated.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/support/deprecated.py b/sources/pyside6/PySide6/support/deprecated.py index f215f2ff5..449a5d2f0 100644 --- a/sources/pyside6/PySide6/support/deprecated.py +++ b/sources/pyside6/PySide6/support/deprecated.py @@ -18,6 +18,8 @@ PYSIDE-1735: This is also used now for missing other functions (overwriting __or in Qt.(Keyboard)Modifier). """ +import inspect +import sys import warnings from textwrap import dedent @@ -68,4 +70,28 @@ def fix_for_QtCore(QtCore): Qt.Modifier.__add__ = func_add Qt.Modifier.__radd__ = func_add + # PYSIDE-2101: Fix rlcompleter until we evict the __signature__ attribute + apply_rlcompleter_patch() + + +def apply_rlcompleter_patch(): + + def _callable_postfix(self, val, word): + if callable(val): + word += "(" + try: + if not inspect.signature(val).parameters: + word += ")" + except ValueError: + pass + # PYSIDE-2101: this line is added because inspect.signature cannot handle lists + except TypeError: + pass + + return word + + if sys.version_info[:2] >= (3, 10): + from rlcompleter import Completer + Completer._callable_postfix = _callable_postfix + # eof |
