bpo-40024: Add PyModule_AddType() helper function (GH-19088)

This commit is contained in:
Dong-hee Na 2020-03-23 01:17:34 +09:00 committed by GitHub
parent b33e52511a
commit 05e4a296ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 52 additions and 42 deletions

View file

@ -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;
}
}