diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-06-09 13:45:07 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-13 14:50:33 +0000 |
commit | 4ecdd2db33a9e275c269bc9219579428d72d6d3e (patch) | |
tree | faed09e01b364f7e5cd62ace329a87af17204fad | |
parent | c4194e272b19baf4f89011cafca4d90c5bde4586 (diff) |
Fix usage of Py_TYPE() for Python 3.11
The macro was changed to a function, no longer allowing for assignment.
Task-number: PYSIDE-1960
Change-Id: I4bc0e9a5c1f3dc70d59628e63b7b9d47ea449992
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit 73adefe22ffbfabe0ef213e9c2fe2c56efdd7488)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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 04b12616e..5f9355f93 100644 --- a/sources/pyside6/libpyside/class_property.cpp +++ b/sources/pyside6/libpyside/class_property.cpp @@ -75,9 +75,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; } @@ -161,7 +161,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 03086a486..46c0f1d6f 100644 --- a/sources/pyside6/libpyside/pysideweakref.cpp +++ b/sources/pyside6/libpyside/pysideweakref.cpp @@ -87,9 +87,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 5efd45a2f..e6e5cd64c 100644 --- a/sources/shiboken6/libshiboken/sbktypefactory.cpp +++ b/sources/shiboken6/libshiboken/sbktypefactory.cpp @@ -116,7 +116,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); |