From 4ab46d794961491ed185c195d53da7ee6a16e646 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 17 Sep 2017 21:11:04 +0300 Subject: 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. --- Objects/exceptions.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'Objects/exceptions.c') diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 1b70be786a..42b3fc7bb1 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); } -- cgit v1.2.1