From f62a1766e5f0cf0e503a76cd755408f2c65dc947 Mon Sep 17 00:00:00 2001 From: Bernd Waibel Date: Wed, 20 Jul 2022 07:29:37 +0200 Subject: [PATCH 3/3] The Fedora / upstream fixes (shiboken2-5.15.2-python311.patch) end up breaking Python 3.8 compatibility (maybe 3.9 too, but didn't get that far). Wrap them with PY_VERSION_HEX for Python 3.11. Original patch no longer applied due to code changes. Signed-off-by: Bernd Waibel --- a/libshiboken/basewrapper.cpp +++ b/libshiboken/basewrapper.cpp @@ -377,7 +377,11 @@ SbkObjectType *SbkObject_TypeF(void) static PyTypeObject *type = nullptr; if (!type) { type = reinterpret_cast(SbkType_FromSpec(&SbkObject_Type_spec)); - Py_SET_TYPE(type, SbkObjectType_TypeF()); + #if PY_VERSION_HEX < 0x030B00A1 + Py_TYPE(type) = SbkObjectType_TypeF(); + #else + Py_SET_TYPE(type, SbkObjectType_TypeF()); + #endif Py_INCREF(Py_TYPE(type)); type->tp_weaklistoffset = offsetof(SbkObject, weakreflist); type->tp_dictoffset = offsetof(SbkObject, ob_dict); @@ -1152,7 +1156,11 @@ introduceWrapperType(PyObject *enclosingObject, typeSpec->slots[0].pfunc = reinterpret_cast(baseType ? baseType : SbkObject_TypeF()); PyObject *heaptype = SbkType_FromSpecWithBases(typeSpec, baseTypes); - Py_SET_TYPE(heaptype, SbkObjectType_TypeF()); + #if PY_VERSION_HEX < 0x030B00A1 + Py_TYPE(heaptype) = SbkObjectType_TypeF(); + #else + Py_SET_TYPE(heaptype, SbkObjectType_TypeF()); + #endif Py_INCREF(Py_TYPE(heaptype)); auto *type = reinterpret_cast(heaptype); #if PY_VERSION_HEX < 0x03000000 --- a/libshiboken/sbkenum.cpp +++ b/libshiboken/sbkenum.cpp @@ -753,7 +753,11 @@ newTypeWithName(const char *name, PyTuple_SetItem(bases, 0, reinterpret_cast(basetype)); auto *type = reinterpret_cast(SbkType_FromSpecWithBases(&newspec, bases)); PyErr_Print(); - Py_SET_TYPE(type, SbkEnumType_TypeF()); + #if PY_VERSION_HEX < 0x030B00A1 + Py_TYPE(type) = SbkEnumType_TypeF(); + #else + Py_SET_TYPE(type, SbkEnumType_TypeF()); + #endif auto *enumType = reinterpret_cast(type); PepType_SETP(enumType)->cppName = cppName;