diff --git a/gi/gimodule.c b/gi/gimodule.c index 0901e738464416b20168fe6b2f31d1c74aaea755..2d1dfe20a71cec2345e0bf8d073b2b4cf9a2cf36 100644 --- a/gi/gimodule.c +++ b/gi/gimodule.c @@ -2253,7 +2253,7 @@ pyg__install_metaclass(PyObject *dummy, PyTypeObject *metaclass) PyGObject_MetaType = metaclass; Py_INCREF(metaclass); - Py_TYPE(&PyGObject_Type) = metaclass; + Py_SET_TYPE(&PyGObject_Type, metaclass); Py_INCREF(Py_None); return Py_None; diff --git a/gi/pygboxed.c b/gi/pygboxed.c index 5659bc120b68504b79c51a9ec18043e2af0a7c48..595f8159172b6a41582fd067bab87a87c2921282 100644 --- a/gi/pygboxed.c +++ b/gi/pygboxed.c @@ -154,7 +154,7 @@ pygi_register_gboxed (PyObject *dict, const gchar *class_name, if (!type->tp_dealloc) type->tp_dealloc = (destructor)gboxed_dealloc; - Py_TYPE(type) = &PyType_Type; + Py_SET_TYPE(type, &PyType_Type); g_assert (Py_TYPE (&PyGBoxed_Type) != NULL); type->tp_base = &PyGBoxed_Type; diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c index 3ab826d7892e9fa18578d328ff8eba143df90f4c..9deb62a7b04a3b221be54e7b6537f503bcd23d5c 100644 --- a/gi/pygi-boxed.c +++ b/gi/pygi-boxed.c @@ -238,7 +238,7 @@ static PyMethodDef boxed_methods[] = { int pygi_boxed_register_types (PyObject *m) { - Py_TYPE(&PyGIBoxed_Type) = &PyType_Type; + Py_SET_TYPE(&PyGIBoxed_Type, &PyType_Type); g_assert (Py_TYPE (&PyGBoxed_Type) != NULL); PyGIBoxed_Type.tp_base = &PyGBoxed_Type; PyGIBoxed_Type.tp_new = (newfunc) boxed_new; diff --git a/gi/pygi-ccallback.c b/gi/pygi-ccallback.c index 897f3c1313328d5dd22ca4b30d3d7397f4a81477..db12f4964b21556bdfa20c22971ccee8aac15fa1 100644 --- a/gi/pygi-ccallback.c +++ b/gi/pygi-ccallback.c @@ -91,7 +91,7 @@ _ccallback_dealloc (PyGICCallback *self) int pygi_ccallback_register_types (PyObject *m) { - Py_TYPE(&PyGICCallback_Type) = &PyType_Type; + Py_SET_TYPE(&PyGICCallback_Type, &PyType_Type); PyGICCallback_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); PyGICCallback_Type.tp_dealloc = (destructor) _ccallback_dealloc; PyGICCallback_Type.tp_call = (ternaryfunc) _ccallback_call; diff --git a/gi/pygi-info.c b/gi/pygi-info.c index cbe8444a6a63864da03d99fabf295f5e96a81351..19894e494077ff9b1d9bd9e1940be6d0efdd907c 100644 --- a/gi/pygi-info.c +++ b/gi/pygi-info.c @@ -2269,7 +2269,7 @@ int pygi_info_register_types (PyObject *m) { #define _PyGI_REGISTER_TYPE(m, type, cname, base) \ - Py_TYPE(&type) = &PyType_Type; \ + Py_SET_TYPE(&type, &PyType_Type); \ type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); \ type.tp_weaklistoffset = offsetof(PyGIBaseInfo, inst_weakreflist); \ type.tp_methods = _PyGI##cname##_methods; \ @@ -2282,7 +2282,7 @@ pygi_info_register_types (PyObject *m) return -1; \ }; - Py_TYPE(&PyGIBaseInfo_Type) = &PyType_Type; + Py_SET_TYPE(&PyGIBaseInfo_Type, &PyType_Type); PyGIBaseInfo_Type.tp_dealloc = (destructor) _base_info_dealloc; PyGIBaseInfo_Type.tp_repr = (reprfunc) _base_info_repr; diff --git a/gi/pygi-repository.c b/gi/pygi-repository.c index a39e7b14097a7b4f1c5b30a02bda1b95d5c251ad..07fdc8f802bfde49e11011329ff7036f4edf1a1b 100644 --- a/gi/pygi-repository.c +++ b/gi/pygi-repository.c @@ -375,7 +375,7 @@ static PyMethodDef _PyGIRepository_methods[] = { int pygi_repository_register_types (PyObject *m) { - Py_TYPE(&PyGIRepository_Type) = &PyType_Type; + Py_SET_TYPE(&PyGIRepository_Type, &PyType_Type); PyGIRepository_Type.tp_flags = Py_TPFLAGS_DEFAULT; PyGIRepository_Type.tp_methods = _PyGIRepository_methods; diff --git a/gi/pygi-resulttuple.c b/gi/pygi-resulttuple.c index 6cb3cbae72ee8bf259d09ce22f3d8daa5fc5cc11..416177bbda70b5d3132620a230623c33f6ff2867 100644 --- a/gi/pygi-resulttuple.c +++ b/gi/pygi-resulttuple.c @@ -289,7 +289,7 @@ pygi_resulttuple_new(PyTypeObject *subclass, Py_ssize_t len) { for (i=0; i < len; i++) { PyTuple_SET_ITEM (self, i, NULL); } - Py_TYPE (self) = subclass; + Py_SET_TYPE (self, subclass); Py_INCREF (subclass); _Py_NewReference (self); PyObject_GC_Track (self); diff --git a/gi/pygi-struct.c b/gi/pygi-struct.c index 51884851c71d144446545fa7ebf8a06bd0dd32a9..f6e75e363a9e89f7342503097e2122699c762806 100644 --- a/gi/pygi-struct.c +++ b/gi/pygi-struct.c @@ -233,7 +233,7 @@ struct_repr(PyGIStruct *self) int pygi_struct_register_types (PyObject *m) { - Py_TYPE(&PyGIStruct_Type) = &PyType_Type; + Py_SET_TYPE(&PyGIStruct_Type, &PyType_Type); g_assert (Py_TYPE (&PyGPointer_Type) != NULL); PyGIStruct_Type.tp_base = &PyGPointer_Type; PyGIStruct_Type.tp_new = (newfunc) struct_new; diff --git a/gi/pygi-type.c b/gi/pygi-type.c index 6f9f7b4b655e3817d1e50bd95b21f1bd128fdc36..c03e74b755b887f91648a8f3de22d9b4be86ebbc 100644 --- a/gi/pygi-type.c +++ b/gi/pygi-type.c @@ -1270,7 +1270,7 @@ pyg_object_descr_doc_get(void) static PyObject *doc_descr = NULL; if (!doc_descr) { - Py_TYPE(&PyGObjectDoc_Type) = &PyType_Type; + Py_SET_TYPE(&PyGObjectDoc_Type, &PyType_Type); if (PyType_Ready(&PyGObjectDoc_Type)) return NULL; diff --git a/gi/pygi-util.h b/gi/pygi-util.h index f67ca8a8027bfcf889b0b79e766bf4664e0f1f67..5a3becf454dce17b866f72848fd1debaf7e83a09 100644 --- a/gi/pygi-util.h +++ b/gi/pygi-util.h @@ -12,6 +12,10 @@ const gchar * pyg_constant_strip_prefix(const gchar *name, const gchar *strip_pr gboolean pygi_guint_from_pyssize (Py_ssize_t pyval, guint *result); +#if PY_VERSION_HEX < 0x030900A4 +# define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0) +#endif + #define PYGI_DEFINE_TYPE(typename, symbol, csymbol) \ PyTypeObject symbol = { \ PyVarObject_HEAD_INIT(NULL, 0) \ diff --git a/gi/pyginterface.c b/gi/pyginterface.c index b6e552963fbf3008f5401fe7ec926a091b6ef222..34db8faccd3d7bab269b9e80165c95537f71e51a 100644 --- a/gi/pyginterface.c +++ b/gi/pyginterface.c @@ -69,7 +69,7 @@ pyg_register_interface(PyObject *dict, const gchar *class_name, { PyObject *o; - Py_TYPE(type) = &PyType_Type; + Py_SET_TYPE(type, &PyType_Type); g_assert (Py_TYPE (&PyGInterface_Type) != NULL); type->tp_base = &PyGInterface_Type; diff --git a/gi/pygobject-object.c b/gi/pygobject-object.c index c59a2cce2870b3418cc2e9280f8933c1d4320e49..961f6dd84a08429b59d493f520b4d9831a3c9181 100644 --- a/gi/pygobject-object.c +++ b/gi/pygobject-object.c @@ -560,7 +560,7 @@ pygobject_register_class(PyObject *dict, const gchar *type_name, } else bases = runtime_bases; - Py_TYPE(type) = PyGObject_MetaType; + Py_SET_TYPE(type, PyGObject_MetaType); type->tp_bases = bases; if (G_LIKELY(bases)) { type->tp_base = (PyTypeObject *)PyTuple_GetItem(bases, 0); diff --git a/gi/pygparamspec.c b/gi/pygparamspec.c index bb94cd9d49953063bda0a6230e94bcc33dc962ce..e49bd36e53cc874133080c496b25373b7999dc8c 100644 --- a/gi/pygparamspec.c +++ b/gi/pygparamspec.c @@ -406,7 +406,7 @@ pyg_param_spec_new(GParamSpec *pspec) int pygi_paramspec_register_types(PyObject *d) { - Py_TYPE(&PyGParamSpec_Type) = &PyType_Type; + Py_SET_TYPE(&PyGParamSpec_Type, &PyType_Type); PyGParamSpec_Type.tp_dealloc = (destructor)pyg_param_spec_dealloc; PyGParamSpec_Type.tp_getattr = (getattrfunc)pyg_param_spec_getattr; PyGParamSpec_Type.tp_richcompare = pyg_param_spec_richcompare; diff --git a/gi/pygpointer.c b/gi/pygpointer.c index fc6482d6e3d08336e61068b82ddd15db8e78f303..6d6b62f9a8747992aa80ba29338a915fe5dee0b8 100644 --- a/gi/pygpointer.c +++ b/gi/pygpointer.c @@ -114,7 +114,7 @@ pyg_register_pointer(PyObject *dict, const gchar *class_name, if (!type->tp_dealloc) type->tp_dealloc = (destructor)pyg_pointer_dealloc; - Py_TYPE(type) = &PyType_Type; + Py_SET_TYPE(type, &PyType_Type); g_assert (Py_TYPE (&PyGPointer_Type) != NULL); type->tp_base = &PyGPointer_Type;