aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken/basewrapper.cpp
diff options
context:
space:
mode:
authorSimo Fält <simo.falt@qt.io>2023-06-29 15:19:20 +0300
committerSimo Fält <simo.falt@qt.io>2023-06-29 15:19:20 +0300
commit568797c36a73aecce050fd198353f31aa986bff9 (patch)
treee1781afe922c4b6327045134639a5c5d41b56300 /sources/shiboken2/libshiboken/basewrapper.cpp
parent643237181d15086816d38cdb17f18147c7ebcbd8 (diff)
parentc76c68a64bb4dce48017c61b4ca021dc6726f77b (diff)
Merge tag 'v5.15.11-lts' into tqtc/lts-5.15-opensourcev5.15.11-lts-lgpl
Qt For Python Release 5.15.11 Change-Id: Idbf9b792238244e185e39be4058a7a2c69458ce9
Diffstat (limited to 'sources/shiboken2/libshiboken/basewrapper.cpp')
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp
index afca7fa08..1919f2825 100644
--- a/sources/shiboken2/libshiboken/basewrapper.cpp
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
@@ -376,8 +376,9 @@ SbkObjectType *SbkObject_TypeF(void)
{
static PyTypeObject *type = nullptr;
if (!type) {
- type = reinterpret_cast<PyTypeObject *>(SbkType_FromSpec(&SbkObject_Type_spec));
- Py_TYPE(type) = SbkObjectType_TypeF();
+ auto *obj = SbkType_FromSpec(&SbkObject_Type_spec);
+ type = reinterpret_cast<PyTypeObject *>(obj);
+ obj->ob_type = SbkObjectType_TypeF();
Py_INCREF(Py_TYPE(type));
type->tp_weaklistoffset = offsetof(SbkObject, weakreflist);
type->tp_dictoffset = offsetof(SbkObject, ob_dict);
@@ -521,7 +522,11 @@ void SbkObjectTypeDealloc(PyObject *pyObj)
PyObject_GC_UnTrack(pyObj);
#ifndef Py_LIMITED_API
+# if PY_VERSION_HEX >= 0x030A0000
+ Py_TRASHCAN_BEGIN(pyObj, 1);
+# else
Py_TRASHCAN_SAFE_BEGIN(pyObj);
+# endif
#endif
if (sotp) {
if (sotp->user_data && sotp->d_func) {
@@ -536,7 +541,11 @@ void SbkObjectTypeDealloc(PyObject *pyObj)
sotp = nullptr;
}
#ifndef Py_LIMITED_API
+# if PY_VERSION_HEX >= 0x030A0000
+ Py_TRASHCAN_END;
+# else
Py_TRASHCAN_SAFE_END(pyObj);
+# endif
#endif
if (PepRuntime_38_flag) {
// PYSIDE-939: Handling references correctly.
@@ -1161,7 +1170,7 @@ introduceWrapperType(PyObject *enclosingObject,
typeSpec->slots[0].pfunc = reinterpret_cast<void *>(baseType ? baseType : SbkObject_TypeF());
PyObject *heaptype = SbkType_FromSpecWithBases(typeSpec, baseTypes);
- Py_TYPE(heaptype) = SbkObjectType_TypeF();
+ heaptype->ob_type = SbkObjectType_TypeF();
Py_INCREF(Py_TYPE(heaptype));
auto *type = reinterpret_cast<SbkObjectType *>(heaptype);
#if PY_VERSION_HEX < 0x03000000
@@ -1526,6 +1535,7 @@ bool setCppPointer(SbkObject *sbkObj, PyTypeObject *desiredType, void *cptr)
bool isValid(PyObject *pyObj)
{
if (!pyObj || pyObj == Py_None
+ || PyType_Check(pyObj) != 0
|| Py_TYPE(Py_TYPE(pyObj)) != SbkObjectType_TypeF()) {
return true;
}