mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue