diff options
author | Christian Tismer <tismer@stackless.com> | 2021-06-13 12:08:41 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-16 15:20:09 +0000 |
commit | b8ebeeb81ce599a9afeef996faaf2f1463ab5981 (patch) | |
tree | d887842fbf2e82ddc24bdc3f19df90327b5e994d | |
parent | c94a2a3520f900674443e4476c184591f03f5541 (diff) |
shiboken: Fix a crash when running .pyi files in Python 3
At the same time, a small overestimate of structures
was fixed: The asterisk was missing here:
PepHeapType_SIZE + sizeof(SbkObjectTypePrivate *);
An omission in module enum_sig was fixed for Qt3DCore:
Instead of __name__, __qualname__ is needed.
Task-number: PYSIDE-1599
Change-Id: Ifd6d70c4c1166a822c8ca517c0d3663c2fc00565
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit 10922e8f48bcd5a018465e663aeeae6023b3ef4c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
3 files changed, 13 insertions, 6 deletions
diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp index 7cb3f25b9..2120ae7e2 100644 --- a/sources/shiboken6/libshiboken/basewrapper.cpp +++ b/sources/shiboken6/libshiboken/basewrapper.cpp @@ -173,7 +173,7 @@ PyTypeObject *SbkObjectType_TypeF(void) // so we can overwrite it a bit. type_getattro = PyType_Type.tp_getattro; SbkObjectType_Type_spec.basicsize = - PepHeapType_SIZE + sizeof(SbkObjectTypePrivate); + PepHeapType_SIZE + sizeof(SbkObjectTypePrivate *); type = reinterpret_cast<PyTypeObject *>(SbkType_FromSpec(&SbkObjectType_Type_spec)); } return type; @@ -635,7 +635,7 @@ static PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyOb Shiboken::ObjectType::initPrivateData(newType); SbkObjectTypePrivate *sotp = PepType_SOTP(newType); - const auto bases = Shiboken::getCppBaseClasses(reinterpret_cast<PyTypeObject *>(newType)); + const auto bases = Shiboken::getCppBaseClasses(&newType->type); if (bases.size() == 1) { SbkObjectTypePrivate *parentType = PepType_SOTP(bases.front()); sotp->mi_offsets = parentType->mi_offsets; @@ -654,8 +654,15 @@ static PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyOb sotp->is_multicpp = 1; sotp->converter = nullptr; } - if (bases.size() == 1) - sotp->original_name = strdup(PepType_SOTP(bases.front())->original_name); + if (bases.size() == 1) { + // PYSIDE-1599 The function `initPrivateData` is called too often. Therefore, + // it can happen that `original_name` is NULL although it was initialized. + // XXX Try to remove `original_name` and improve the initialization. + const char *original_name = PepType_SOTP(bases.front())->original_name; + if (original_name == nullptr) + original_name = "object"; + sotp->original_name = strdup(original_name); + } else sotp->original_name = strdup("object"); sotp->user_data = nullptr; diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py index 28898deb1..743e1c9e2 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/enum_sig.py @@ -118,7 +118,7 @@ class ExactEnumerator(object): return ret bases_list = [] for base in klass.__bases__: - name = base.__name__ + name = base.__qualname__ if name not in ("object", "property", "type"): name = base.__module__ + "." + name bases_list.append(name) diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py index 3c4efebda..bffecc2b1 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/lib/pyi_generator.py @@ -316,7 +316,7 @@ def generate_pyi(import_name, outpath, options): if options and options.check or is_ci: # Python 3.7 and up: We can check the file directly if the syntax is ok. if USE_PEP563: - subprocess.check_output([sys.executable, outfilepath]) + subprocess.check_output([sys.executable, os.fspath(outfilepath)]) if __name__ == "__main__": |