[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.37,2.38
Guido van Rossum
gvanrossum@users.sourceforge.net
Thu, 16 Aug 2001 11:52:46 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv20253
Modified Files:
typeobject.c
Log Message:
Fix object_repr() to include the module (using the same rules as
type_repr() for when to show or not to show it).
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.37
retrieving revision 2.38
diff -C2 -d -r2.37 -r2.38
*** typeobject.c 2001/08/16 15:42:49 2.37
--- typeobject.c 2001/08/16 18:52:43 2.38
***************
*** 913,919 ****
object_repr(PyObject *self)
{
! char buf[120];
! sprintf(buf, "<%.80s object at %p>", self->ob_type->tp_name, self);
return PyString_FromString(buf);
}
--- 913,940 ----
object_repr(PyObject *self)
{
! PyTypeObject *type;
! PyObject *mod, *name;
! char buf[200];
! type = self->ob_type;
! mod = type_module(type, NULL);
! if (mod == NULL)
! PyErr_Clear();
! else if (!PyString_Check(mod)) {
! Py_DECREF(mod);
! mod = NULL;
! }
! name = type_name(type, NULL);
! if (name == NULL)
! return NULL;
! if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__"))
! sprintf(buf, "<%.80s.%.80s instance at %p>",
! PyString_AS_STRING(mod),
! PyString_AS_STRING(name),
! self);
! else
! sprintf(buf, "<%.80s instance at %p>", type->tp_name, self);
! Py_XDECREF(mod);
! Py_DECREF(name);
return PyString_FromString(buf);
}