summaryrefslogtreecommitdiff
path: root/gi
diff options
context:
space:
mode:
authorTomas Hrnciar <thrnciar@redhat.com>2020-11-06 12:25:38 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2020-11-11 10:09:10 +0100
commitba67301beea4b4a7a19485f68215b0f0d52888be (patch)
treee65d66e7d0129a9f683d80c8ecf1e74d6724b83e /gi
parentc28e4da87ab9411baa081c47e67574a1ea059493 (diff)
downloadpygobject-ba67301beea4b4a7a19485f68215b0f0d52888be.tar.gz
Don't assume Py_TYPE being a macro
Py_TYPE was changed to a function in Python 3.10. Suggested approach is to use Py_SET_TYPE macro instead, see: https://docs.python.org/3.10/whatsnew/3.10.html.
Diffstat (limited to 'gi')
-rw-r--r--gi/gimodule.c2
-rw-r--r--gi/pygboxed.c2
-rw-r--r--gi/pygi-boxed.c2
-rw-r--r--gi/pygi-ccallback.c2
-rw-r--r--gi/pygi-info.c4
-rw-r--r--gi/pygi-repository.c2
-rw-r--r--gi/pygi-resulttuple.c2
-rw-r--r--gi/pygi-struct.c2
-rw-r--r--gi/pygi-type.c2
-rw-r--r--gi/pygi-util.h4
-rw-r--r--gi/pyginterface.c2
-rw-r--r--gi/pygobject-object.c2
-rw-r--r--gi/pygparamspec.c2
-rw-r--r--gi/pygpointer.c2
14 files changed, 18 insertions, 14 deletions
diff --git a/gi/gimodule.c b/gi/gimodule.c
index 0901e738..2d1dfe20 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 5659bc12..595f8159 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 3ab826d7..9deb62a7 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 897f3c13..db12f496 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 cbe8444a..19894e49 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 a39e7b14..07fdc8f8 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 6cb3cbae..416177bb 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 51884851..f6e75e36 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 6f9f7b4b..c03e74b7 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 f67ca8a8..5a3becf4 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 b6e55296..34db8fac 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 c59a2cce..961f6dd8 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 bb94cd9d..e49bd36e 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 fc6482d6..6d6b62f9 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;