aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-05-01 14:47:05 +0200
committerChristian Tismer <tismer@stackless.com>2021-05-22 11:51:39 +0000
commit0eb2cde3fee7e3cdc2e1273001ae532c499680e5 (patch)
tree3762ea09d748fb5eb3d0ba6f94d9131f9a962a73 /sources
parent1adb18fc3166ee4bd15bf4921b1f11ae44f62d03 (diff)
__feature__: Ensure that features are not affected by other imports
Imports should not touch the feature dict unless they are feature imports. This was a small error in the import logic. (also fixed a const_cast glitch) Change-Id: I16045fffb4b770861ff2efba674667894e0798e5 Fixes: PYSIDE-1548 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 39ba36db0fb8a3c722cb23e02f38abab9c67592c) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r--sources/pyside2/tests/QtCore/snake_prop_feature_test.py2
-rw-r--r--sources/shiboken2/libshiboken/signature/signature.cpp2
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/feature.py11
3 files changed, 7 insertions, 8 deletions
diff --git a/sources/pyside2/tests/QtCore/snake_prop_feature_test.py b/sources/pyside2/tests/QtCore/snake_prop_feature_test.py
index 779b8a408..aea6a22ab 100644
--- a/sources/pyside2/tests/QtCore/snake_prop_feature_test.py
+++ b/sources/pyside2/tests/QtCore/snake_prop_feature_test.py
@@ -88,6 +88,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(QtWidgets.QWidget.modal, property))
self.assertTrue(isinstance(window.modal, bool))
diff --git a/sources/shiboken2/libshiboken/signature/signature.cpp b/sources/shiboken2/libshiboken/signature/signature.cpp
index 8cda6f810..6880ea1f2 100644
--- a/sources/shiboken2/libshiboken/signature/signature.cpp
+++ b/sources/shiboken2/libshiboken/signature/signature.cpp
@@ -436,7 +436,7 @@ static PyObject *adjustFuncName(const char *func_name)
* Note that fget is impossible because there are no parameters.
*/
static const char mapping_name[] = "shibokensupport.signature.mapping";
- static PyObject *sys_modules = PySys_GetObject("modules");
+ static PyObject *sys_modules = PySys_GetObject(const_cast<char *>("modules"));
static PyObject *mapping = PyDict_GetItemString(sys_modules, mapping_name);
static PyObject *ns = PyModule_GetDict(mapping);
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/feature.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/feature.py
index fe3491f9e..8bd8856ff 100644
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/feature.py
+++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/feature.py
@@ -114,13 +114,10 @@ def _import(name, *args, **kwargs):
sys.modules["PySide2.QtCore"].__init_feature__()
return sys.modules["__feature__"]
- if name.split(".")[0] == "PySide2":
- # This is a module that imports PySide2.
- 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] == "PySide2" else -1
+ pyside_feature_dict[importing_module] = default
return original_import(name, *args, **kwargs)
_is_initialized = False