summaryrefslogtreecommitdiffstats
path: root/Objects/odictobject.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/odictobject.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/odictobject.c')
-rw-r--r--Objects/odictobject.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index 8ad8f38..afacb36 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -1471,16 +1471,9 @@ odict_repr(PyODictObject *self)
int i;
_Py_IDENTIFIER(items);
PyObject *pieces = NULL, *result = NULL;
- const char *classname;
-
- classname = strrchr(Py_TYPE(self)->tp_name, '.');
- if (classname == NULL)
- classname = Py_TYPE(self)->tp_name;
- else
- classname++;
if (PyODict_SIZE(self) == 0)
- return PyUnicode_FromFormat("%s()", classname);
+ return PyUnicode_FromFormat("%s()", _PyType_Name(Py_TYPE(self)));
i = Py_ReprEnter((PyObject *)self);
if (i != 0) {
@@ -1532,7 +1525,8 @@ odict_repr(PyODictObject *self)
goto Done;
}
- result = PyUnicode_FromFormat("%s(%R)", classname, pieces);
+ result = PyUnicode_FromFormat("%s(%R)",
+ _PyType_Name(Py_TYPE(self)), pieces);
Done:
Py_XDECREF(pieces);