diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-06-09 13:45:07 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-06-13 13:35:58 +0200 |
commit | 73adefe22ffbfabe0ef213e9c2fe2c56efdd7488 (patch) | |
tree | d14a76c8ed45c73f4e5f3b7611fe6465224b9ed6 /sources | |
parent | fd6f5801117e6c3d215e9b53b8bf5a8e8506ae78 (diff) |
Fix usage of Py_TYPE() for Python 3.11
The macro was changed to a function, no longer allowing for assignment.
Pick-to: 6.3 6.2 5.15
Task-number: PYSIDE-1960
Change-Id: I4bc0e9a5c1f3dc70d59628e63b7b9d47ea449992
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/pyside6/libpyside/class_property.cpp | 6 | ||||
-rw-r--r-- | sources/pyside6/libpyside/pysideweakref.cpp | 8 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/sbktypefactory.cpp | 2 |
3 files changed, 9 insertions, 7 deletions
diff --git a/sources/pyside6/libpyside/class_property.cpp b/sources/pyside6/libpyside/class_property.cpp index 9deb022f1..c255ef1e9 100644 --- a/sources/pyside6/libpyside/class_property.cpp +++ b/sources/pyside6/libpyside/class_property.cpp @@ -39,9 +39,9 @@ static int PyClassProperty_descr_set(PyObject *self, PyObject *obj, PyObject *va static int PyClassProperty_tp_init(PyObject *self, PyObject *args, PyObject *kwargs) { auto hold = Py_TYPE(self); - Py_TYPE(self) = &PyProperty_Type; + self->ob_type = &PyProperty_Type; auto ret = PyProperty_Type.tp_init(self, args, kwargs); - Py_TYPE(self) = hold; + self->ob_type = hold; return ret; } @@ -125,7 +125,7 @@ void init(PyObject *module) { PyTypeObject *type = SbkObjectType_TypeF(); type->tp_setattro = SbkObjectType_meta_setattro; - Py_TYPE(PyClassProperty_TypeF()) = type; + reinterpret_cast<PyObject *>(type)->ob_type = type; if (InitSignatureStrings(PyClassProperty_TypeF(), PyClassProperty_SignatureStrings) < 0) return; diff --git a/sources/pyside6/libpyside/pysideweakref.cpp b/sources/pyside6/libpyside/pysideweakref.cpp index 2554055e3..79a19fec8 100644 --- a/sources/pyside6/libpyside/pysideweakref.cpp +++ b/sources/pyside6/libpyside/pysideweakref.cpp @@ -51,9 +51,11 @@ PyObject *create(PyObject *obj, PySideWeakRefFunction func, void *userData) if (obj == Py_None) return nullptr; - if (Py_TYPE(PySideCallableObject_TypeF()) == nullptr) { - Py_TYPE(PySideCallableObject_TypeF()) = &PyType_Type; - PyType_Ready(PySideCallableObject_TypeF()); + auto *callableObject_Type = PySideCallableObject_TypeF(); + auto *callableObject_PyObject = reinterpret_cast<PyObject *>(callableObject_Type); + if (callableObject_PyObject->ob_type == nullptr) { + callableObject_PyObject->ob_type = &PyType_Type; + PyType_Ready(callableObject_Type); } PyTypeObject *type = PySideCallableObject_TypeF(); diff --git a/sources/shiboken6/libshiboken/sbktypefactory.cpp b/sources/shiboken6/libshiboken/sbktypefactory.cpp index e117bdb8b..0da1a8e23 100644 --- a/sources/shiboken6/libshiboken/sbktypefactory.cpp +++ b/sources/shiboken6/libshiboken/sbktypefactory.cpp @@ -80,7 +80,7 @@ PyTypeObject *SbkType_FromSpec_BMDWB(PyType_Spec *spec, if (meta) { PyTypeObject *hold = Py_TYPE(type); - Py_TYPE(type) = meta; + obType->ob_type = meta; Py_INCREF(Py_TYPE(type)); if (hold->tp_flags & Py_TPFLAGS_HEAPTYPE) Py_DECREF(hold); |