diff options
author | Christian Tismer <tismer@stackless.com> | 2021-03-21 13:08:07 +0100 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2021-03-23 22:25:04 +0100 |
commit | ca2b448344b3b1ed8715fba85ddbb3be9f766fbb (patch) | |
tree | 81c1989544d7866c5f47bda475170b41d1a7ebbf /sources | |
parent | ea35d748ec16822a4b845e8e839ecd04f59ac763 (diff) |
PySide import: Make imports more safe against installation errors
This patch originally was
"__feature__: Make imports more safe against installation errors"
After applying the patch to 5.15 with errors, it became clear that
not __feature__ was a problem, but the "import PySideX.support"
did not work in the embedding case.
This observation made the error message concerning PyInstaller
pointless. Instead, the pseudo-import of PySideX.support was fixed
to work correctly in all cases.
Tested on 5.15 with PyInstaller, this is now going back into dev.
Task-number: PYSIDE-1502
Change-Id: I2fd680a6a28de00f5392147b0d050deb7663dc22
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py index 9313cb663..698ad4c75 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py @@ -175,7 +175,8 @@ def move_into_pyside_package(): try: import PySide6.support except ModuleNotFoundError: - PySide6.support = types.ModuleType("PySide6.support") + # This can happen in the embedding case. + put_into_package(PySide6, shibokensupport, "support") put_into_package(PySide6.support, __feature__, "__feature__") put_into_package(PySide6.support, signature) put_into_package(PySide6.support.signature, mapping) @@ -198,7 +199,7 @@ from shibokensupport.signature import importhandler from shibokensupport.signature.lib import enum_sig if "PySide6" in sys.modules: - # We publish everything under "PySide6.support.signature", again. + # We publish everything under "PySide6.support", again. move_into_pyside_package() # PYSIDE-1502: Make sure that support can be imported. try: @@ -206,17 +207,12 @@ if "PySide6" in sys.modules: except ModuleNotFoundError as e: print("PySide6.support could not be imported. " "This is a serious configuration error.", file=sys.stderr) - raise e from None + raise # PYSIDE-1019: Modify `__import__` to be `__feature__` aware. # __feature__ is already in sys.modules, so this is actually no import - try: - import PySide6.support.__feature__ - sys.modules["__feature__"] = PySide6.support.__feature__ - PySide6.support.__feature__.original_import = __builtins__["__import__"] - __builtins__["__import__"] = PySide6.support.__feature__._import - # Maybe we should optimize that and change `__import__` from C, instead? - except ModuleNotFoundError: - print("__feature__ could not be imported. " - "This may be an unsolved PyInstaller problem.", file=sys.stderr) + import PySide6.support.__feature__ + sys.modules["__feature__"] = PySide6.support.__feature__ + PySide6.support.__feature__.original_import = __builtins__["__import__"] + __builtins__["__import__"] = PySide6.support.__feature__._import # end of file |