diff Objects/typeobject.c @ 42040:96eefc7a67a0

Simplify error formatting and type_repr().
author Walter Dörwald <walter@livinglogic.de>
date Mon, 11 Jun 2007 15:47:13 +0000
parents 180846b8755f
children 05f1fd31344d
line wrap: on
line diff
--- a/Objects/typeobject.c	Mon Jun 11 15:37:20 2007 +0000
+++ b/Objects/typeobject.c	Mon Jun 11 15:47:13 2007 +0000
@@ -384,12 +384,8 @@
 	else
 		kind = "type";
 
-	if (mod != NULL && strcmp(PyUnicode_AsString(mod), "__builtin__")) {
-		rtn = PyUnicode_FromFormat("<%s '%s.%s'>",
-					  kind,
-					  PyUnicode_AsString(mod),
-					  PyUnicode_AsString(name));
-	}
+	if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "__builtin__"))
+		rtn = PyUnicode_FromFormat("<%s '%U.%U'>", kind, mod, name);
 	else
 		rtn = PyUnicode_FromFormat("<%s '%s'>", kind, type->tp_name);
 
@@ -2155,8 +2151,8 @@
 
 	/* Give up */
 	PyErr_Format(PyExc_AttributeError,
-			 "type object '%.50s' has no attribute '%.400s'",
-			 type->tp_name, PyUnicode_AsString(name));
+	             "type object '%.50s' has no attribute '%U'",
+	             type->tp_name, name);
 	return NULL;
 }