summaryrefslogtreecommitdiffstats
path: root/Objects/exceptions.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-09-17 18:11:04 (GMT)
committerGitHub <noreply@github.com>2017-09-17 18:11:04 (GMT)
commit4ab46d794961491ed185c195d53da7ee6a16e646 (patch)
treed8c39fb69ba33674cf8a240f6d068d0cf710d7a3 /Objects/exceptions.c
parent132a7d7cdbc7cb89fa1c1f4e8192241c3d68f549 (diff)
downloadcpython-4ab46d794961491ed185c195d53da7ee6a16e646.zip
cpython-4ab46d794961491ed185c195d53da7ee6a16e646.tar.gz
cpython-4ab46d794961491ed185c195d53da7ee6a16e646.tar.bz2
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.
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r--Objects/exceptions.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 1b70be7..42b3fc7 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -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);
}