aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2023-03-15 11:18:23 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-03-20 09:18:37 +0000
commitf73f8562f5e1a40667c9fd43b9adf7c0c2ee4401 (patch)
tree02b20defe6b8d5945582605963308c2dfb7d9990
parent30af29f8112e25390dee42669a1d9fe21e2d566d (diff)
shiboken: Fix getOverride to support private methods
Private methods generate no wrappers, and so the logic in BindingManager::getOverride does not work. Return the method as-is in this case. An acknowledgment goes to Friedemann for the right idea. And a -2 for Gerrit's pickiness :) Fixes: PYSIDE-2255 Change-Id: If1f0bcc037c7c190eaedab1a245b35062c426783 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 10b3c162647d0d25e34bf1e3ae5b2ce57c89f324) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/libshiboken/bindingmanager.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/sources/shiboken6/libshiboken/bindingmanager.cpp b/sources/shiboken6/libshiboken/bindingmanager.cpp
index 5e884d892..2698de724 100644
--- a/sources/shiboken6/libshiboken/bindingmanager.cpp
+++ b/sources/shiboken6/libshiboken/bindingmanager.cpp
@@ -323,17 +323,23 @@ PyObject *BindingManager::getOverride(const void *cptr,
PyObject *mro = Py_TYPE(wrapper)->tp_mro;
int size = PyTuple_GET_SIZE(mro);
+ bool defaultFound = false;
// The first class in the mro (index 0) is the class being checked and it should not be tested.
// The last class in the mro (size - 1) is the base Python object class which should not be tested also.
for (int idx = 1; idx < size - 1; ++idx) {
auto *parent = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx));
if (parent->tp_dict) {
defaultMethod = PyDict_GetItem(parent->tp_dict, pyMethodName);
- if (defaultMethod && function != defaultMethod)
- return method;
+ if (defaultMethod) {
+ defaultFound = true;
+ if (function != defaultMethod)
+ return method;
+ }
}
}
-
+ // PYSIDE-2255: If no default method was found, use the method.
+ if (!defaultFound)
+ return method;
Py_DECREF(method);
}