summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2020-11-08 14:56:42 +0000
committerChristoph Reiter <reiter.christoph@gmail.com>2020-11-08 14:56:42 +0000
commitc4d7d21a2ad838077c6310532fdf7505321f0ae7 (patch)
tree111e7e8b6feaa6b4627b6bcb784b87b33a85096c
parent10b1a869da09d260e54b6f28a0d2c0e3015deee4 (diff)
parent89e0c07e4aa991af307b113afa474fcdfffe0859 (diff)
downloadgobject-introspection-c4d7d21a2ad838077c6310532fdf7505321f0ae7.tar.gz
Merge branch 'py-type-assign' into 'master'
Don't assume Py_TYPE being a macro Closes #358 See merge request GNOME/gobject-introspection!243
-rw-r--r--giscanner/giscannermodule.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/giscanner/giscannermodule.c b/giscanner/giscannermodule.c
index 43f8bdea..46bfd105 100644
--- a/giscanner/giscannermodule.c
+++ b/giscanner/giscannermodule.c
@@ -27,10 +27,6 @@
#include <glib-object.h>
-#ifndef Py_TYPE
- #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
-#endif
-
#if PY_MAJOR_VERSION >= 3
#define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
#define MOD_ERROR_RETURN NULL
@@ -52,8 +48,12 @@ PyTypeObject Py##cname##_Type = { \
0 \
}
+#if PY_VERSION_HEX < 0x030900A4
+# define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
+#endif
+
#define REGISTER_TYPE(d, name, type) \
- Py_TYPE(&type) = &PyType_Type; \
+ Py_SET_TYPE(&type, &PyType_Type); \
type.tp_alloc = PyType_GenericAlloc; \
type.tp_new = PyType_GenericNew; \
type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; \