aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2024-03-27 18:06:28 +0100
committerChristian Tismer <tismer@stackless.com>2024-03-28 08:38:52 +0100
commit7b709cf594d9c308b57eacd784845beff9c72c2f (patch)
tree53d34dd73d78c9e86674faea34dcc1caef3a64cb /sources/shiboken6
parentdafa49070d45ab6b8ccd1a80b0e05597599c8e80 (diff)
Implement multiple inheritance correctly, 2nd. amendment
When a Python class does _not_ implement __init__, then we might get the default of object.__init__, which must be skipped like the object class alone. Change-Id: I0416c97854e8d1c9edf0b9ac44d3df58223fef84 Fixes: PYSIDE-2654 Task-number: PYSIDE-2294 Pick-to: 6.5 6.6 6.7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken6')
-rw-r--r--sources/shiboken6/libshiboken/bindingmanager.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/sources/shiboken6/libshiboken/bindingmanager.cpp b/sources/shiboken6/libshiboken/bindingmanager.cpp
index a9b87f7f4..a0acc4e4b 100644
--- a/sources/shiboken6/libshiboken/bindingmanager.cpp
+++ b/sources/shiboken6/libshiboken/bindingmanager.cpp
@@ -408,6 +408,8 @@ bool callInheritedInit(PyObject *self, PyObject *args, PyObject *kwds,
using Shiboken::AutoDecRef;
static PyObject *const _init = String::createStaticString("__init__");
+ static PyObject *objectInit =
+ PyObject_GetAttr(reinterpret_cast<PyObject *>(&PyBaseObject_Type), _init);
// A native C++ self cannot have multiple inheritance.
if (!Object::isUserType(self))
@@ -441,6 +443,10 @@ bool callInheritedInit(PyObject *self, PyObject *args, PyObject *kwds,
if (subType == &PyBaseObject_Type)
return false;
AutoDecRef func(PyObject_GetAttr(obSubType, _init));
+ // PYSIDE-2654: If this has no implementation then we get object.__init__
+ // but that is the same case like above.
+ if (func == objectInit)
+ return false;
// PYSIDE-2294: We need to explicitly ignore positional args in a mixin class.
SBK_UNUSED(args);
AutoDecRef newArgs(PyTuple_New(1));