mirror of
https://github.com/python/cpython.git
synced 2025-12-05 00:52:25 +00:00
Simplify error formatting and type_repr().
This commit is contained in:
parent
d376dd9700
commit
75163600de
1 changed files with 4 additions and 8 deletions
|
|
@ -384,12 +384,8 @@ type_repr(PyTypeObject *type)
|
||||||
else
|
else
|
||||||
kind = "type";
|
kind = "type";
|
||||||
|
|
||||||
if (mod != NULL && strcmp(PyUnicode_AsString(mod), "__builtin__")) {
|
if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "__builtin__"))
|
||||||
rtn = PyUnicode_FromFormat("<%s '%s.%s'>",
|
rtn = PyUnicode_FromFormat("<%s '%U.%U'>", kind, mod, name);
|
||||||
kind,
|
|
||||||
PyUnicode_AsString(mod),
|
|
||||||
PyUnicode_AsString(name));
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
rtn = PyUnicode_FromFormat("<%s '%s'>", kind, type->tp_name);
|
rtn = PyUnicode_FromFormat("<%s '%s'>", kind, type->tp_name);
|
||||||
|
|
||||||
|
|
@ -2155,8 +2151,8 @@ type_getattro(PyTypeObject *type, PyObject *name)
|
||||||
|
|
||||||
/* Give up */
|
/* Give up */
|
||||||
PyErr_Format(PyExc_AttributeError,
|
PyErr_Format(PyExc_AttributeError,
|
||||||
"type object '%.50s' has no attribute '%.400s'",
|
"type object '%.50s' has no attribute '%U'",
|
||||||
type->tp_name, PyUnicode_AsString(name));
|
type->tp_name, name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue