diff options
author | Christian Tismer <tismer@stackless.com> | 2023-03-15 11:18:23 +0100 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2023-03-16 17:32:29 +0100 |
commit | 10b3c162647d0d25e34bf1e3ae5b2ce57c89f324 (patch) | |
tree | 5c2b725540c3ab2d4c693f8e5f871c426c16975a /sources | |
parent | f668df2e26803989a4d4730ae219767bc9f229a9 (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
Pick-to: 6.4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/shiboken6/libshiboken/bindingmanager.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sources/shiboken6/libshiboken/bindingmanager.cpp b/sources/shiboken6/libshiboken/bindingmanager.cpp index 8a7475bb9..01e073020 100644 --- a/sources/shiboken6/libshiboken/bindingmanager.cpp +++ b/sources/shiboken6/libshiboken/bindingmanager.cpp @@ -324,17 +324,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); } |