aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2022-12-02 13:47:48 +0100
committerChristian Tismer <tismer@stackless.com>2022-12-13 11:26:19 +0100
commite20e29d1bd03f6ff9e57037d0a7f35bb59604f4e (patch)
tree3031f8f9b89879fd27950e63a346651338058ba1 /sources/shiboken6
parentd09302d50bf64afdf7eae0075134bb554c9d1166 (diff)
__feature__: Fix a weird case of false metafunction lookup
PySide implements duck-punching since 2010. This could create a problem with true_property since 06/2019, because a meta-function could be found in the instance dict of a QObject class, although the methods were replaced by a property object. This was an unexpected reaction of the `getMetaDataFromQObject` function. Meta methods were created and inserted into the instance dict, which caused very unrelated side effects like infinite recursion. The new implementation handles Python properties correctly and looks up the hidden methods if necessary without side effects. There are no longer meta functions involved. The function `getMetaDataFromQObject` is misleading and was replaced by `getHiddenDataFromQObject`, keeping the old name as an alias. It will be finally removed in version 6.5 . [ChangeLog][PySide6] A callback error when using true_property was fixed. Change-Id: Ie5234eab2106885f6edad24ae7d4c55fff43d62f Fixes: PYSIDE-1889 Pick-to: 6.4 Task-number: PYSIDE-1019 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6')
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp2
-rw-r--r--sources/shiboken6/libshiboken/bindingmanager.cpp2
-rw-r--r--sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py5
3 files changed, 7 insertions, 2 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 1b4a04dd4..48006d788 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -6438,7 +6438,7 @@ QString CppGenerator::qObjectGetAttroFunction() const
if (result.isEmpty()) {
auto qobjectClass = AbstractMetaClass::findClass(api().classes(), qObjectT());
Q_ASSERT(qobjectClass);
- result = u"PySide::getMetaDataFromQObject("_s
+ result = u"PySide::getHiddenDataFromQObject("_s
+ cpythonWrapperCPtr(qobjectClass, u"self"_s)
+ u", self, name)"_s;
}
diff --git a/sources/shiboken6/libshiboken/bindingmanager.cpp b/sources/shiboken6/libshiboken/bindingmanager.cpp
index 9d74e9721..5e884d892 100644
--- a/sources/shiboken6/libshiboken/bindingmanager.cpp
+++ b/sources/shiboken6/libshiboken/bindingmanager.cpp
@@ -276,6 +276,8 @@ PyObject *BindingManager::getOverride(const void *cptr,
auto *obWrapper = reinterpret_cast<PyObject *>(wrapper);
auto *wrapper_dict = SbkObject_GetDict_NoRef(obWrapper);
if (PyObject *method = PyDict_GetItem(wrapper_dict, pyMethodName)) {
+ // Note: This special case was implemented for duck-punching, which happens
+ // in the instance dict. It does not work with properties.
Py_INCREF(method);
return method;
}
diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
index 5d86b93a5..63127ae93 100644
--- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
+++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py
@@ -70,6 +70,7 @@ def _get_flag_enum_option():
if not isinstance(flag, int):
flag = True
p = f"\n *** Python is at version {'.'.join(map(str, pyminver or (0,)))} now."
+ q = f"\n *** PySide is at version {'.'.join(map(str, ver[:2]))} now."
# PYSIDE-1797: Emit a warning when we may remove pep384_issue33738.cpp
if pyminver and pyminver >= (3, 8):
warnings.warn(f"{p} The file pep384_issue33738.cpp should be removed ASAP! ***")
@@ -81,7 +82,9 @@ def _get_flag_enum_option():
warnings.warn(f"{p} The files bufferprocs_py37.(cpp|h) should be removed ASAP! ***")
# PYSIDE-1735: Emit a warning when we should maybe evict forgiveness mode
if ver[:2] >= (7, 0):
- warnings.warn(f"{p} Please drop Enum forgiveness mode in `mangled_type_getattro` ***")
+ warnings.warn(f"{q} Please drop Enum forgiveness mode in `mangled_type_getattro` ***")
+ if ver[:2] >= (6, 5):
+ warnings.warn(f"{q} Please drop the misleading function `getMetaDataFromQObject` ***")
# normalize the sys attribute
setattr(sys, sysname, flag)
os.environ[envname] = str(flag)