summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Sottile <alby128@gmail.com>2019-02-22 11:23:48 +0100
committerAlberto Sottile <alby128@gmail.com>2019-02-22 13:52:50 +0000
commitf324cced79a004d6ecb698a01189500384d0f966 (patch)
tree06ba24052f51728472bad0122c20ee0dbed54318
parent4c48e8e53fc566270bb639f09bb2de3d5ddbd5cf (diff)
Fix error when importing signatures in frozen executables
Attempts to load the module directly from Python if loading it manually from the .py file fails. This exposes the support submodule to installers. The loader.py module was also patched to allow direct import from installers. Change-Id: If225ae7a2e916912a581e09d1a02c18fd3a17526 Fixes: PYSIDE-942 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/shiboken2/libshiboken/signature.cpp7
-rw-r--r--sources/shiboken2/shibokenmodule/support/signature/loader.py34
2 files changed, 24 insertions, 17 deletions
diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp
index da9c56c6..d6c26ac7 100644
--- a/sources/shiboken2/libshiboken/signature.cpp
+++ b/sources/shiboken2/libshiboken/signature.cpp
@@ -445,8 +445,11 @@ static const char PySide_PythonCode[] =
with open(__file__) as _f:
exec(compile(_f.read(), __file__, 'exec'))
except Exception as e:
- print('Exception:', e)
- traceback.print_exc(file=sys.stdout)
+ try:
+ from shiboken2.support.signature import loader
+ except:
+ print('Exception:', e)
+ traceback.print_exc(file=sys.stdout)
globals().update(locals())
)~";
diff --git a/sources/shiboken2/shibokenmodule/support/signature/loader.py b/sources/shiboken2/shibokenmodule/support/signature/loader.py
index 40ad95bd..45875984 100644
--- a/sources/shiboken2/shibokenmodule/support/signature/loader.py
+++ b/sources/shiboken2/shibokenmodule/support/signature/loader.py
@@ -134,6 +134,21 @@ def formatannotation(annotation, base_module=None):
def _typevar__repr__(self):
return "typing." + self.__name__
+# Note also that during the tests we have a different encoding that would
+# break the Python license decorated files without an encoding line.
+
+# name used in signature.cpp
+def create_signature(props, key):
+ return layout.create_signature(props, key)
+
+# name used in signature.cpp
+def seterror_argument(args, func_name):
+ return errorhandler.seterror_argument(args, func_name)
+
+# name used in signature.cpp
+def make_helptext(func):
+ return errorhandler.make_helptext(func)
+
with ensure_import_support():
# We store all needed modules in signature_loader.
# This way, they are always accessible.
@@ -197,21 +212,10 @@ with ensure_import_support():
from support.signature.lib import enum_sig
put_into_loader_package(enum_sig)
from support.signature.parser import pyside_type_init
+ put_into_loader_package(pyside_type_init)
+ put_into_loader_package(create_signature)
+ put_into_loader_package(seterror_argument)
+ put_into_loader_package(make_helptext)
-# Note also that during the tests we have a different encoding that would
-# break the Python license decorated files without an encoding line.
-
-# name used in signature.cpp
-def create_signature(props, key):
- return layout.create_signature(props, key)
-
-# name used in signature.cpp
-def seterror_argument(args, func_name):
- return errorhandler.seterror_argument(args, func_name)
-
-# name used in signature.cpp
-def make_helptext(func):
- return errorhandler.make_helptext(func)
-
# end of file