aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside6/tests/QtCore/snake_prop_feature_test.py2
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py12
2 files changed, 7 insertions, 7 deletions
diff --git a/sources/pyside6/tests/QtCore/snake_prop_feature_test.py b/sources/pyside6/tests/QtCore/snake_prop_feature_test.py
index 6bfcddec0..7925c4c0c 100644
--- a/sources/pyside6/tests/QtCore/snake_prop_feature_test.py
+++ b/sources/pyside6/tests/QtCore/snake_prop_feature_test.py
@@ -91,6 +91,8 @@ class FeatureTest(unittest.TestCase):
window.modal
from __feature__ import snake_case, true_property
+ #PYSIDE-1548: Make sure that another import does not clear the features.
+ import sys
self.assertTrue(isinstance(QWidget.modal, property))
self.assertTrue(isinstance(window.modal, bool))
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py
index 2ee12a6b4..b6d6657fe 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/feature.py
@@ -118,6 +118,7 @@ def feature_import(name, *args, **kwargs):
# PYSIDE-1368: The `__name__` attribute does not need to exist in all modules.
# PYSIDE-1398: sys._getframe(1) may not exist when embedding.
# PYSIDE-1338: The "1" below is the redirection in loader.py .
+ # PYSIDE-1548: Ensure that features are not affected by other imports.
calling_frame = _cf = sys._getframe(1).f_back
importing_module = _cf.f_globals.get("__name__", "__main__") if _cf else "__main__"
existing = pyside_feature_dict.get(importing_module, 0)
@@ -145,13 +146,10 @@ def feature_import(name, *args, **kwargs):
sys.modules["PySide6.QtCore"].__init_feature__()
return sys.modules["__feature__"]
- if name.split(".")[0] == "PySide6":
- # This is a module that imports PySide6.
- flag = existing if isinstance(existing, int) else 0
- else:
- # This is some other module. Ignore it in switching.
- flag = -1
- pyside_feature_dict[importing_module] = flag
+ if importing_module not in pyside_feature_dict:
+ # Ignore new modules if not from PySide.
+ default = 0 if name.split(".")[0] == "PySide6" else -1
+ pyside_feature_dict[importing_module] = default
# Redirect to the original import
return None