diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2020-03-22 16:17:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-22 16:17:34 (GMT) |
commit | 05e4a296ecc127641160a04f39cc02c0f66a8c27 (patch) | |
tree | 59e73090785087a5e15175c815a20986e59a5728 /Modules/itertoolsmodule.c | |
parent | b33e52511a59c6da7132c226b7f7489b092a33eb (diff) | |
download | cpython-05e4a296ecc127641160a04f39cc02c0f66a8c27.zip cpython-05e4a296ecc127641160a04f39cc02c0f66a8c27.tar.gz cpython-05e4a296ecc127641160a04f39cc02c0f66a8c27.tar.bz2 |
bpo-40024: Add PyModule_AddType() helper function (GH-19088)
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r-- | Modules/itertoolsmodule.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 72fd3d7..83d1bb1 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -4724,21 +4724,13 @@ itertoolsmodule_exec(PyObject *m) &groupby_type, &_grouper_type, &tee_type, - &teedataobject_type, - NULL + &teedataobject_type }; Py_SET_TYPE(&teedataobject_type, &PyType_Type); - for (int i = 0; typelist[i] != NULL; i++) { - PyTypeObject *type = typelist[i]; - if (PyType_Ready(type) < 0) { - return -1; - } - const char *name = _PyType_Name(type); - Py_INCREF(type); - if (PyModule_AddObject(m, name, (PyObject *)type) < 0) { - Py_DECREF(type); + for (size_t i = 0; i < Py_ARRAY_LENGTH(typelist); i++) { + if (PyModule_AddType(m, typelist[i]) < 0) { return -1; } } |