diff options
author | Christian Tismer <tismer@stackless.com> | 2021-03-13 19:10:56 +0100 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2021-03-17 14:47:55 +0100 |
commit | 5c8ec34aa21469a1814682fe9b63ed79082c4661 (patch) | |
tree | 9388f02205769f4587696347a09da1bd9ac77a63 /sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py | |
parent | f930fce091fbcc0cdc4d1d57ee688966b26ea53e (diff) |
__feature__: Make imports more safe against installation errors
PySide is sometimes installed by modified installer scripts.
The __feature__ script may be problematic due to dunder usage.
We therefore remove dunder and use it internally, only.
The __feature__ also has a problem with PyInstaller (maybe solved
by the above) and does not work. But if somebody did an omission,
a false error message can be generated.
As a cure, we explicitly test the import of PySide6.support before
we import the pseudo module PySide6.support.__feature__ . This is
an unconditional error, while a missing feature import is just
a warning.
Task-number: PYSIDE-1502
Change-Id: Ia4feaa67b615581291d1c7ff0c5fbdf40a2f176f
Pick-to: 5.15
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py')
-rw-r--r-- | sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py index e685da166..9313cb663 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/loader.py @@ -112,7 +112,7 @@ def finish_import(module): import signature_bootstrap -from shibokensupport import signature, __feature__ +from shibokensupport import signature, feature as __feature__ signature.get_signature = signature_bootstrap.get_signature # PYSIDE-1019: Publish the __feature__ dictionary. __feature__.pyside_feature_dict = signature_bootstrap.pyside_feature_dict @@ -176,7 +176,7 @@ def move_into_pyside_package(): import PySide6.support except ModuleNotFoundError: PySide6.support = types.ModuleType("PySide6.support") - put_into_package(PySide6.support, __feature__) + put_into_package(PySide6.support, __feature__, "__feature__") put_into_package(PySide6.support, signature) put_into_package(PySide6.support.signature, mapping) put_into_package(PySide6.support.signature, errorhandler) @@ -200,6 +200,13 @@ from shibokensupport.signature.lib import enum_sig if "PySide6" in sys.modules: # We publish everything under "PySide6.support.signature", again. move_into_pyside_package() + # PYSIDE-1502: Make sure that support can be imported. + try: + import PySide6.support + except ModuleNotFoundError as e: + print("PySide6.support could not be imported. " + "This is a serious configuration error.", file=sys.stderr) + raise e from None # PYSIDE-1019: Modify `__import__` to be `__feature__` aware. # __feature__ is already in sys.modules, so this is actually no import try: @@ -210,6 +217,6 @@ if "PySide6" in sys.modules: # Maybe we should optimize that and change `__import__` from C, instead? except ModuleNotFoundError: print("__feature__ could not be imported. " - "This is an unsolved PyInstaller problem.", file=sys.stderr) + "This may be an unsolved PyInstaller problem.", file=sys.stderr) # end of file |