From 5aabea13afc4aa1f18b862a19aeeea23be8b5a7b Mon Sep 17 00:00:00 2001 From: Matt Wilson Date: Wed, 3 Oct 2001 15:46:24 +0000 Subject: tweak the repr such that calling it on an uninitialized PyGObject won't 2001-10-03 Matt Wilson * gobjectmodule.c (pygobject_repr): tweak the repr such that calling it on an uninitialized PyGObject won't segfault. Also print the python class name. --- gobject/gobjectmodule.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gobject/gobjectmodule.c') diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index f842397..3067b20 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -1131,10 +1131,13 @@ pygobject_hash(PyGObject *self) static PyObject * pygobject_repr(PyGObject *self) { - gchar buf[128]; + gchar buf[256]; - g_snprintf(buf, sizeof(buf), "<%s at 0x%lx>", G_OBJECT_TYPE_NAME(self->obj), - (long)self->obj); + g_snprintf(buf, sizeof(buf), + "<%s object (%s) at 0x%lx>", + self->ob_type->tp_name, + self->obj ? G_OBJECT_TYPE_NAME(self->obj) : "uninitialized", + (long)self); return PyString_FromString(buf); } -- cgit