[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.72,2.73
Guido van Rossum
gvanrossum@users.sourceforge.net
Mon, 24 Sep 2001 20:56:31 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv9052/Objects
Modified Files:
typeobject.c
Log Message:
Change repr() of a new-style class to say <class 'ClassName'> rather
than <type 'ClassName'>. Exception: if it's a built-in type or an
extension type, continue to call it <type 'ClassName>. Call me a
wimp, but I don't want to break more user code than necessary.
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.72
retrieving revision 2.73
diff -C2 -d -r2.72 -r2.73
*** typeobject.c 2001/09/25 03:43:42 2.72
--- typeobject.c 2001/09/25 03:56:29 2.73
***************
*** 115,118 ****
--- 115,119 ----
{
PyObject *mod, *name, *rtn;
+ char *kind;
mod = type_module(type, NULL);
***************
*** 127,137 ****
return NULL;
if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__")) {
! rtn = PyString_FromFormat("<type '%s.%s'>",
PyString_AS_STRING(mod),
PyString_AS_STRING(name));
}
else
! rtn = PyString_FromFormat("<type '%s'>", type->tp_name);
Py_XDECREF(mod);
--- 128,144 ----
return NULL;
+ if (type->tp_flags & Py_TPFLAGS_HEAPTYPE)
+ kind = "class";
+ else
+ kind = "type";
+
if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__")) {
! rtn = PyString_FromFormat("<%s '%s.%s'>",
! kind,
PyString_AS_STRING(mod),
PyString_AS_STRING(name));
}
else
! rtn = PyString_FromFormat("<%s '%s'>", kind, type->tp_name);
Py_XDECREF(mod);
***************
*** 3366,3375 ****
if (su->obj)
return PyString_FromFormat(
! "<super: <type '%s'>, <%s object>>",
su->type ? su->type->tp_name : "NULL",
su->obj->ob_type->tp_name);
else
return PyString_FromFormat(
! "<super: <type '%s'>, NULL>",
su->type ? su->type->tp_name : "NULL");
}
--- 3373,3382 ----
if (su->obj)
return PyString_FromFormat(
! "<super: <class '%s'>, <%s object>>",
su->type ? su->type->tp_name : "NULL",
su->obj->ob_type->tp_name);
else
return PyString_FromFormat(
! "<super: <class '%s'>, NULL>",
su->type ? su->type->tp_name : "NULL");
}