diff options
| -rw-r--r-- | sources/shiboken6/libshiboken/basewrapper.cpp | 2 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.cpp | 20 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.h | 3 |
3 files changed, 6 insertions, 19 deletions
diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp index 99aea4725..6c1d4bf1f 100644 --- a/sources/shiboken6/libshiboken/basewrapper.cpp +++ b/sources/shiboken6/libshiboken/basewrapper.cpp @@ -333,8 +333,6 @@ static PyTypeObject *createObjectType() offsetof(SbkObject, ob_dict), offsetof(SbkObject, weakreflist), nullptr); // bufferprocs - // Initialize the hidden data area. - _PepPostInit_SbkObject_Type(type); return type; } diff --git a/sources/shiboken6/libshiboken/pep384impl.cpp b/sources/shiboken6/libshiboken/pep384impl.cpp index 4826fb379..f926107e2 100644 --- a/sources/shiboken6/libshiboken/pep384impl.cpp +++ b/sources/shiboken6/libshiboken/pep384impl.cpp @@ -1009,9 +1009,12 @@ long _PepRuntimeVersion() SbkObjectTypePrivate *PepType_SOTP(PyTypeObject *type) { + // PYSIDE-2676: Use the meta type explicitly. + // A derived type would fail the offset calculation. + static auto *meta = SbkObjectType_TypeF(); assert(SbkObjectType_Check(type)); auto *obType = reinterpret_cast<PyObject *>(type); - void *data = PyObject_GetTypeData(obType, Py_TYPE(obType)); + void *data = PyObject_GetTypeData(obType, meta); return reinterpret_cast<SbkObjectTypePrivate *>(data); } @@ -1061,11 +1064,12 @@ static thread_local SbkObjectTypePrivate *SOTP_value{}; SbkObjectTypePrivate *PepType_SOTP(PyTypeObject *type) { + static auto *meta = SbkObjectType_TypeF(); static bool use_312 = _PepRuntimeVersion() >= 0x030C00; assert(SbkObjectType_Check(type)); if (use_312) { auto *obType = reinterpret_cast<PyObject *>(type); - void *data = PepObject_GetTypeData(obType, Py_TYPE(obType)); + void *data = PepObject_GetTypeData(obType, meta); return reinterpret_cast<SbkObjectTypePrivate *>(data); } if (type == SOTP_key) @@ -1092,18 +1096,6 @@ void PepType_SOTP_delete(PyTypeObject *type) #endif // !defined(Py_LIMITED_API) && PY_VERSION_HEX >= 0x030C0000 -void _PepPostInit_SbkObject_Type(PyTypeObject *type) -{ - // Special init for SbkObject_Type. - // A normal initialization would recurse PepType_SOTP. - if (_PepRuntimeVersion() >= 0x030C00) { - auto *obType = reinterpret_cast<PyObject *>(type); - void *data = PepObject_GetTypeData(obType, Py_TYPE(obType)); - auto *sbkExt = reinterpret_cast<SbkObjectTypePrivate *>(data); - std::fill_n(reinterpret_cast<char *>(data), sizeof(*sbkExt), 0); - } -} - /* * SbkEnumType extender */ diff --git a/sources/shiboken6/libshiboken/pep384impl.h b/sources/shiboken6/libshiboken/pep384impl.h index 31fd65219..ec58aac81 100644 --- a/sources/shiboken6/libshiboken/pep384impl.h +++ b/sources/shiboken6/libshiboken/pep384impl.h @@ -156,9 +156,6 @@ struct SbkObjectTypePrivate; LIBSHIBOKEN_API SbkObjectTypePrivate *PepType_SOTP(PyTypeObject *type); LIBSHIBOKEN_API void PepType_SOTP_delete(PyTypeObject *type); -// PYSIDE-2230: SbkObjectType needs a special init -LIBSHIBOKEN_API void _PepPostInit_SbkObject_Type(PyTypeObject *type); - struct SbkEnumType; struct SbkEnumTypePrivate; |
