summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog22
-rw-r--r--glib/pyglib-python-compat.h2
-rw-r--r--gobject/gobjectmodule.c6
-rw-r--r--gobject/pygboxed.c7
-rw-r--r--gobject/pygenum.c2
-rw-r--r--gobject/pyginterface.c5
-rw-r--r--gobject/pygobject.c24
-rw-r--r--gobject/pygparamspec.c2
-rw-r--r--gobject/pygpointer.c7
-rw-r--r--gobject/pygtype.c10
10 files changed, 57 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 4dd5365..35be8fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,28 @@
2008-07-27 Johan Dahlin <johan@gnome.org>
* glib/pyglib-python-compat.h:
+ * gobject/gobjectmodule.c (pyg_object_new),
+ (pyg__install_metaclass):
+ * gobject/pygboxed.c (pyg_boxed_dealloc), (pyg_boxed_init),
+ (pyg_register_boxed):
+ * gobject/pygenum.c (pyg_enum_reduce):
+ * gobject/pyginterface.c (pyg_interface_init),
+ (pyg_register_interface):
+ * gobject/pygobject.c (pygobject_get_inst_data),
+ (pygobject_register_class), (pygobject_new_with_interfaces),
+ (pygobject_dealloc), (pygobject_repr), (pygobject_emit),
+ (pygobject_chain_from_overridden), (pygobject_weak_ref_notify):
+ * gobject/pygparamspec.c (pygobject_paramspec_register_types):
+ * gobject/pygpointer.c (pyg_pointer_dealloc), (pyg_pointer_init),
+ (pyg_register_pointer):
+ * gobject/pygtype.c (pyg_type_from_object),
+ (pyg_value_array_from_pyobject), (pyg_value_from_pyobject),
+ (pyg_object_descr_doc_get):
+ Use the Py_TYPE macro everywhere.
+
+2008-07-27 Johan Dahlin <johan@gnome.org>
+
+ * glib/pyglib-python-compat.h:
Add a Py_TYPE macro for accessing ob_type.
* glib/glibmodule.c (pyglib_register_constants):
* gobject/gobjectmodule.c (pygobject__g_instance_init),
diff --git a/glib/pyglib-python-compat.h b/glib/pyglib-python-compat.h
index 0fb4601..83357a8 100644
--- a/glib/pyglib-python-compat.h
+++ b/glib/pyglib-python-compat.h
@@ -45,7 +45,7 @@ typedef int Py_ssize_t;
#define _PyLongObject PyIntObject
#define _PyLong_Type PyInt_Type
#define _PyLong_AS_LONG PyInt_AS_LONG
-#define Py_TYPE(ob) (ob->ob_type)
+#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#else
#undef PYGLIB_MODULE_START
#undef PYGLIB_MODULE_END
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index 7fb9154..a95aede 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -1715,7 +1715,7 @@ pyg_object_new (PyGObject *self, PyObject *args, PyObject *kwargs)
value, pspec) < 0) {
PyErr_Format(PyExc_TypeError,
"could not convert value for property `%s' from %s to %s",
- key_str, value->ob_type->tp_name,
+ key_str, Py_TYPE(value)->tp_name,
g_type_name(G_PARAM_SPEC_VALUE_TYPE(pspec)));
goto cleanup;
}
@@ -1944,7 +1944,9 @@ pyg__install_metaclass(PyObject *dummy, PyTypeObject *metaclass)
Py_INCREF(metaclass);
PyGObject_MetaType = metaclass;
Py_INCREF(metaclass);
- PyGObject_Type.ob_type = metaclass;
+
+ Py_TYPE(&PyGObject_Type) = metaclass;
+
Py_INCREF(Py_None);
return Py_None;
}
diff --git a/gobject/pygboxed.c b/gobject/pygboxed.c
index bf41fb8..aea6089 100644
--- a/gobject/pygboxed.c
+++ b/gobject/pygboxed.c
@@ -42,7 +42,7 @@ pyg_boxed_dealloc(PyGBoxed *self)
pyglib_gil_state_release(state);
}
- self->ob_type->tp_free((PyObject *)self);
+ Py_TYPE(self)->tp_free((PyObject *)self);
}
static int
@@ -81,7 +81,8 @@ pyg_boxed_init(PyGBoxed *self, PyObject *args, PyObject *kwargs)
self->gtype = 0;
self->free_on_dealloc = FALSE;
- g_snprintf(buf, sizeof(buf), "%s can not be constructed", self->ob_type->tp_name);
+ g_snprintf(buf, sizeof(buf), "%s can not be constructed",
+ Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_NotImplementedError, buf);
return -1;
}
@@ -129,7 +130,7 @@ pyg_register_boxed(PyObject *dict, const gchar *class_name,
if (!type->tp_dealloc) type->tp_dealloc = (destructor)pyg_boxed_dealloc;
- type->ob_type = &PyType_Type;
+ Py_TYPE(type) = &PyType_Type;
type->tp_base = &PyGBoxed_Type;
if (PyType_Ready(type) < 0) {
diff --git a/gobject/pygenum.c b/gobject/pygenum.c
index e35f738..5b30fc1 100644
--- a/gobject/pygenum.c
+++ b/gobject/pygenum.c
@@ -278,7 +278,7 @@ pyg_enum_reduce(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, ":GEnum.__reduce__"))
return NULL;
- return Py_BuildValue("(O(i)O)", self->ob_type, _PyLong_AsLong(self),
+ return Py_BuildValue("(O(i)O)", Py_TYPE(self), _PyLong_AsLong(self),
PyObject_GetAttrString(self, "__dict__"));
}
diff --git a/gobject/pyginterface.c b/gobject/pyginterface.c
index 815df30..2a17574 100644
--- a/gobject/pyginterface.c
+++ b/gobject/pyginterface.c
@@ -41,7 +41,8 @@ pyg_interface_init(PyObject *self, PyObject *args, PyObject *kwargs)
if (!PyArg_ParseTuple(args, ":GInterface.__init__"))
return -1;
- g_snprintf(buf, sizeof(buf), "%s can not be constructed", self->ob_type->tp_name);
+ g_snprintf(buf, sizeof(buf), "%s can not be constructed",
+ Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_NotImplementedError, buf);
return -1;
}
@@ -69,7 +70,7 @@ pyg_register_interface(PyObject *dict, const gchar *class_name,
{
PyObject *o;
- type->ob_type = &PyType_Type;
+ Py_TYPE(type) = &PyType_Type;
type->tp_base = &PyGInterface_Type;
if (PyType_Ready(type) < 0) {
diff --git a/gobject/pygobject.c b/gobject/pygobject.c
index 720fad9..0c43d4d 100644
--- a/gobject/pygobject.c
+++ b/gobject/pygobject.c
@@ -97,7 +97,7 @@ pygobject_get_inst_data(PyGObject *self)
{
inst_data = pygobject_data_new();
- inst_data->type = ((PyObject *)self)->ob_type;
+ inst_data->type = Py_TYPE(self);
Py_INCREF((PyObject *) inst_data->type);
g_object_set_qdata_full(self->obj, pygobject_instance_data_key,
@@ -497,7 +497,7 @@ pygobject_register_class(PyObject *dict, const gchar *type_name,
} else
bases = runtime_bases;
- type->ob_type = PyGObject_MetaType;
+ Py_TYPE(type) = PyGObject_MetaType;
type->tp_bases = bases;
if (G_LIKELY(bases)) {
type->tp_base = (PyTypeObject *)PyTuple_GetItem(bases, 0);
@@ -694,7 +694,7 @@ pygobject_new_with_interfaces(GType gtype)
type_name = g_strconcat(mod_name, ".", gtype_name, NULL);
}
- type = (PyTypeObject*)PyObject_CallFunction((PyObject *) py_parent_type->ob_type,
+ type = (PyTypeObject*)PyObject_CallFunction((PyObject *) Py_TYPE(py_parent_type),
"sNN", type_name, bases, dict);
g_free(type_name);
@@ -897,7 +897,7 @@ pygobject_dealloc(PyGObject *self)
pygobject_get_inst_data(self);
pygobject_clear(self);
/* the following causes problems with subclassed types */
- /* self->ob_type->tp_free((PyObject *)self); */
+ /* Py_TYPE(self)->tp_free((PyObject *)self); */
PyObject_GC_Del(self);
}
@@ -922,7 +922,7 @@ pygobject_repr(PyGObject *self)
g_snprintf(buf, sizeof(buf),
"<%s object at 0x%lx (%s at 0x%lx)>",
- self->ob_type->tp_name,
+ Py_TYPE(self)->tp_name,
(long)self,
self->obj ? G_OBJECT_TYPE_NAME(self->obj) : "uninitialized",
(long)self->obj);
@@ -1066,7 +1066,7 @@ pygobject__gobject_init__(PyGObject *self, PyObject *args, PyObject *kwargs)
if (!G_IS_OBJECT(self->obj)) { \
PyErr_Format(PyExc_TypeError, \
"object at %p of type %s is not initialized", \
- self, self->ob_type->tp_name); \
+ self, Py_TYPE(self)->tp_name); \
return NULL; \
}
@@ -1622,8 +1622,8 @@ pygobject_emit(PyGObject *self, PyObject *args)
if (pyg_value_from_pyobject(&params[i+1], item) < 0) {
gchar buf[128];
g_snprintf(buf, sizeof(buf),
- "could not convert type %s to %s required for parameter %d",
- item->ob_type->tp_name,
+ "could not convert type %s to %s required for parameter %d",
+ Py_TYPE(item)->tp_name,
g_type_name(G_VALUE_TYPE(&params[i+1])), i);
PyErr_SetString(PyExc_TypeError, buf);
@@ -1734,9 +1734,9 @@ pygobject_chain_from_overridden(PyGObject *self, PyObject *args)
gchar buf[128];
g_snprintf(buf, sizeof(buf),
- "could not convert type %s to %s required for parameter %d",
- item->ob_type->tp_name,
- g_type_name(G_VALUE_TYPE(&params[i+1])), i);
+ "could not convert type %s to %s required for parameter %d",
+ Py_TYPE(item)->tp_name,
+ g_type_name(G_VALUE_TYPE(&params[i+1])), i);
PyErr_SetString(PyExc_TypeError, buf);
for (i = 0; i < query.n_params + 1; i++)
g_value_unset(&params[i]);
@@ -2007,7 +2007,7 @@ pygobject_weak_ref_notify(PyGObjectWeakRef *self, GObject *dummy)
PyErr_Format(PyExc_TypeError,
"GObject weak notify callback returned a value"
" of type %s, should return None",
- retval->ob_type->tp_name);
+ Py_TYPE(retval)->tp_name);
Py_DECREF(retval);
PyErr_Print();
} else
diff --git a/gobject/pygparamspec.c b/gobject/pygparamspec.c
index c52efeb..c4b68ec 100644
--- a/gobject/pygparamspec.c
+++ b/gobject/pygparamspec.c
@@ -384,7 +384,7 @@ pyg_param_spec_new(GParamSpec *pspec)
void
pygobject_paramspec_register_types(PyObject *d)
{
- PyGParamSpec_Type.ob_type = &PyType_Type;
+ Py_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_compare = (cmpfunc)pyg_param_spec_compare;
diff --git a/gobject/pygpointer.c b/gobject/pygpointer.c
index d06118e..5f88b31 100644
--- a/gobject/pygpointer.c
+++ b/gobject/pygpointer.c
@@ -35,7 +35,7 @@ PYGLIB_DEFINE_TYPE("gobject.GPointer", PyGPointer_Type, PyGPointer);
static void
pyg_pointer_dealloc(PyGPointer *self)
{
- self->ob_type->tp_free((PyObject *)self);
+ Py_TYPE(self)->tp_free((PyObject *)self);
}
static int
@@ -73,7 +73,8 @@ pyg_pointer_init(PyGPointer *self, PyObject *args, PyObject *kwargs)
self->pointer = NULL;
self->gtype = 0;
- g_snprintf(buf, sizeof(buf), "%s can not be constructed", self->ob_type->tp_name);
+ g_snprintf(buf, sizeof(buf), "%s can not be constructed",
+ Py_TYPE(self)->tp_name);
PyErr_SetString(PyExc_NotImplementedError, buf);
return -1;
}
@@ -107,7 +108,7 @@ pyg_register_pointer(PyObject *dict, const gchar *class_name,
if (!type->tp_dealloc) type->tp_dealloc = (destructor)pyg_pointer_dealloc;
- type->ob_type = &PyType_Type;
+ Py_TYPE(&type) = &PyType_Type;
type->tp_base = &PyGPointer_Type;
if (PyType_Ready(type) < 0) {
diff --git a/gobject/pygtype.c b/gobject/pygtype.c
index d04b550..715ed39 100644
--- a/gobject/pygtype.c
+++ b/gobject/pygtype.c
@@ -337,7 +337,7 @@ pyg_type_from_object(PyObject *obj)
return PY_TYPE_OBJECT;
}
- if (obj->ob_type == &PyGTypeWrapper_Type) {
+ if (Py_TYPE(obj) == &PyGTypeWrapper_Type) {
return ((PyGTypeWrapper *)obj)->type;
}
@@ -355,7 +355,7 @@ pyg_type_from_object(PyObject *obj)
gtype = PyObject_GetAttrString(obj, "__gtype__");
if (gtype) {
- if (gtype->ob_type == &PyGTypeWrapper_Type) {
+ if (Py_TYPE(gtype) == &PyGTypeWrapper_Type) {
type = ((PyGTypeWrapper *)gtype)->type;
Py_DECREF(gtype);
return type;
@@ -607,7 +607,7 @@ pyg_value_array_from_pyobject(GValue *value,
else if (item == Py_None)
type = G_TYPE_POINTER; /* store None as NULL */
else {
- type = pyg_type_from_object((PyObject *) item->ob_type);
+ type = pyg_type_from_object((PyObject*)Py_TYPE(item));
if (! type) {
PyErr_Clear();
g_value_array_free(value_array);
@@ -834,7 +834,7 @@ pyg_value_from_pyobject(GValue *value, PyObject *obj)
GType type;
GValue *n_value;
- type = pyg_type_from_object((PyObject *)obj->ob_type);
+ type = pyg_type_from_object((PyObject*)Py_TYPE(obj));
if (G_UNLIKELY (! type)) {
PyErr_Clear();
return -1;
@@ -1507,7 +1507,7 @@ pyg_object_descr_doc_get(void)
static PyObject *doc_descr = NULL;
if (!doc_descr) {
- PyGObjectDoc_Type.ob_type = &PyType_Type;
+ Py_TYPE(&PyGObjectDoc_Type) = &PyType_Type;
if (PyType_Ready(&PyGObjectDoc_Type))
return NULL;