summaryrefslogtreecommitdiffstats
path: root/Modules/_functoolsmodule.c
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-03-22 16:17:34 (GMT)
committerGitHub <noreply@github.com>2020-03-22 16:17:34 (GMT)
commit05e4a296ecc127641160a04f39cc02c0f66a8c27 (patch)
tree59e73090785087a5e15175c815a20986e59a5728 /Modules/_functoolsmodule.c
parentb33e52511a59c6da7132c226b7f7489b092a33eb (diff)
downloadcpython-05e4a296ecc127641160a04f39cc02c0f66a8c27.zip
cpython-05e4a296ecc127641160a04f39cc02c0f66a8c27.tar.gz
cpython-05e4a296ecc127641160a04f39cc02c0f66a8c27.tar.bz2
bpo-40024: Add PyModule_AddType() helper function (GH-19088)
Diffstat (limited to 'Modules/_functoolsmodule.c')
-rw-r--r--Modules/_functoolsmodule.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index 0c0fae1..ff733b8 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -1431,13 +1431,10 @@ static struct PyModuleDef _functoolsmodule = {
PyMODINIT_FUNC
PyInit__functools(void)
{
- int i;
PyObject *m;
- const char *name;
PyTypeObject *typelist[] = {
&partial_type,
- &lru_cache_type,
- NULL
+ &lru_cache_type
};
m = PyModule_Create(&_functoolsmodule);
@@ -1450,14 +1447,11 @@ PyInit__functools(void)
return NULL;
}
- for (i=0 ; typelist[i] != NULL ; i++) {
- if (PyType_Ready(typelist[i]) < 0) {
+ for (size_t i = 0; i < Py_ARRAY_LENGTH(typelist); i++) {
+ if (PyModule_AddType(m, typelist[i]) < 0) {
Py_DECREF(m);
return NULL;
}
- name = _PyType_Name(typelist[i]);
- Py_INCREF(typelist[i]);
- PyModule_AddObject(m, name, (PyObject *)typelist[i]);
}
return m;
}