mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-40024: Add PyModule_AddType() helper function (GH-19088)
This commit is contained in:
parent
b33e52511a
commit
05e4a296ec
10 changed files with 52 additions and 42 deletions
|
@ -2565,21 +2565,13 @@ collections_exec(PyObject *module) {
|
|||
&PyODict_Type,
|
||||
&dequeiter_type,
|
||||
&dequereviter_type,
|
||||
&tuplegetter_type,
|
||||
NULL,
|
||||
&tuplegetter_type
|
||||
};
|
||||
|
||||
defdict_type.tp_base = &PyDict_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(module, name, (PyObject *)type) < 0) {
|
||||
Py_DECREF(type);
|
||||
for (size_t i = 0; i < Py_ARRAY_LENGTH(typelist); i++) {
|
||||
if (PyModule_AddType(module, typelist[i]) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue