57 lines
2.1 KiB
Diff
57 lines
2.1 KiB
Diff
--- a/sources/shiboken2/libshiboken/basewrapper.cpp
|
|
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
|
|
@@ -64,6 +64,12 @@
|
|
#include <dlfcn.h>
|
|
#endif
|
|
|
|
+#if PY_VERSION_HEX < 0x03090000
|
|
+void Py_SET_TYPE(PyObject *o, PyTypeObject *type) {
|
|
+ Py_TYPE(o) = type;
|
|
+}
|
|
+#endif
|
|
+
|
|
namespace {
|
|
void _destroyParentInfo(SbkObject *obj, bool keepReference);
|
|
}
|
|
@@ -377,7 +383,7 @@ SbkObjectType *SbkObject_TypeF(void)
|
|
static PyTypeObject *type = nullptr;
|
|
if (!type) {
|
|
type = reinterpret_cast<PyTypeObject *>(SbkType_FromSpec(&SbkObject_Type_spec));
|
|
- Py_TYPE(type) = SbkObjectType_TypeF();
|
|
+ Py_SET_TYPE(type, SbkObjectType_TypeF());
|
|
Py_INCREF(Py_TYPE(type));
|
|
type->tp_weaklistoffset = offsetof(SbkObject, weakreflist);
|
|
type->tp_dictoffset = offsetof(SbkObject, ob_dict);
|
|
@@ -1152,7 +1158,7 @@ introduceWrapperType(PyObject *enclosing
|
|
typeSpec->slots[0].pfunc = reinterpret_cast<void *>(baseType ? baseType : SbkObject_TypeF());
|
|
|
|
PyObject *heaptype = SbkType_FromSpecWithBases(typeSpec, baseTypes);
|
|
- Py_TYPE(heaptype) = SbkObjectType_TypeF();
|
|
+ Py_SET_TYPE(heaptype, SbkObjectType_TypeF());
|
|
Py_INCREF(Py_TYPE(heaptype));
|
|
auto *type = reinterpret_cast<SbkObjectType *>(heaptype);
|
|
#if PY_VERSION_HEX < 0x03000000
|
|
--- a/sources/shiboken2/libshiboken/sbkenum.cpp
|
|
+++ b/sources/shiboken2/libshiboken/sbkenum.cpp
|
|
@@ -55,6 +55,11 @@
|
|
#define SbkEnumType_Check(o) (Py_TYPE(Py_TYPE(o)) == SbkEnumType_TypeF())
|
|
typedef PyObject *(*enum_func)(PyObject *, PyObject *);
|
|
|
|
+#if PY_VERSION_HEX < 0x03090000
|
|
+void Py_SET_TYPE(PyObject *o, PyTypeObject *type) {
|
|
+ Py_TYPE(o) = type;
|
|
+}
|
|
+#endif
|
|
extern "C"
|
|
{
|
|
|
|
@@ -753,7 +758,7 @@ newTypeWithName(const char *name,
|
|
PyTuple_SetItem(bases, 0, reinterpret_cast<PyObject *>(basetype));
|
|
auto *type = reinterpret_cast<PyTypeObject *>(SbkType_FromSpecWithBases(&newspec, bases));
|
|
PyErr_Print();
|
|
- Py_TYPE(type) = SbkEnumType_TypeF();
|
|
+ Py_SET_TYPE(type, SbkEnumType_TypeF());
|
|
|
|
auto *enumType = reinterpret_cast<SbkEnumType *>(type);
|
|
PepType_SETP(enumType)->cppName = cppName;
|