summaryrefslogtreecommitdiffstats
path: root/Modules/_functoolsmodule.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 /Modules/_functoolsmodule.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 'Modules/_functoolsmodule.c')
-rw-r--r--Modules/_functoolsmodule.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index e109b33..a571045 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -1284,7 +1284,7 @@ PyInit__functools(void)
{
int i;
PyObject *m;
- char *name;
+ const char *name;
PyTypeObject *typelist[] = {
&partial_type,
&lru_cache_type,
@@ -1306,10 +1306,9 @@ PyInit__functools(void)
Py_DECREF(m);
return NULL;
}
- name = strchr(typelist[i]->tp_name, '.');
- assert (name != NULL);
+ name = _PyType_Name(typelist[i]);
Py_INCREF(typelist[i]);
- PyModule_AddObject(m, name+1, (PyObject *)typelist[i]);
+ PyModule_AddObject(m, name, (PyObject *)typelist[i]);
}
return m;
}