From 4457db11f873b29bd46c268126cbbdea6b397eee Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Thu, 6 Aug 2020 14:13:36 +0200 Subject: shiboken: warn if the signature module fails to initialize There are setup errors that fail to initialize the signature module correctly. This is for instance possible if packaging puts the shiboken2 module somewhere into the path, but the binary cannot be reached, because shiboken2 also exists as a dictionary. Task-number: PYSIDE-1352 Change-Id: I679d6855c87093b946cfbaeb063c10d45b00c8ad Reviewed-by: Cristian Maureira-Fredes --- sources/pyside2/PySide2/__init__.py.in | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sources/pyside2/PySide2/__init__.py.in b/sources/pyside2/PySide2/__init__.py.in index f860c6ac9..5c33c57a0 100644 --- a/sources/pyside2/PySide2/__init__.py.in +++ b/sources/pyside2/PySide2/__init__.py.in @@ -1,6 +1,7 @@ from __future__ import print_function import os import sys +from textwrap import dedent __all__ = list("Qt" + body for body in "@all_module_shortnames@" @@ -62,7 +63,20 @@ def _setupQtDirectories(): raise # Trigger signature initialization. - type.__signature__ + try: + type.__signature__ + except AttributeError: + print(dedent('''\ + {stars} + PySide2/__init__.py: The `signature` module was not initialized. + This libshiboken module was loaded from + + "{shiboken2.__file__}". + + Please make sure that this is the real shiboken2 binary and not just a folder. + {stars} + ''').format(stars=79*"*", **locals()), file=sys.stderr) + raise if sys.platform == 'win32': # PATH has to contain the package directory, otherwise plugins -- cgit v1.2.3