mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bpo-31497: Add private helper _PyType_Name(). (#3630)
This function returns the last component of tp_name after a dot. Returns tp_name itself if it doesn't contain a dot.
This commit is contained in:
parent
132a7d7cdb
commit
4ab46d7949
6 changed files with 26 additions and 33 deletions
|
|
@ -116,13 +116,7 @@ BaseException_str(PyBaseExceptionObject *self)
|
|||
static PyObject *
|
||||
BaseException_repr(PyBaseExceptionObject *self)
|
||||
{
|
||||
const char *name;
|
||||
const char *dot;
|
||||
|
||||
name = Py_TYPE(self)->tp_name;
|
||||
dot = (const char *) strrchr(name, '.');
|
||||
if (dot != NULL) name = dot+1;
|
||||
|
||||
const char *name = _PyType_Name(Py_TYPE(self));
|
||||
return PyUnicode_FromFormat("%s%R", name, self->args);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue