aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2022-11-14 18:24:23 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-11-15 12:26:00 +0000
commitf554b6068053edda928ee11c3f7046945266345d (patch)
tree07094dc50aaafe311f6cb6580c20334d14b535f3
parent46ad931370e37b1e3abe5db9d52d57a3ec83151d (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 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 95e9f8fd675c6e4f1eeabe9337a7cb9c1e3b4456) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/pyside6/PySide6/support/deprecated.py26
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