mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +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
|
@ -678,3 +678,22 @@ PyModule_AddStringConstant(PyObject *m, const char *name, const char *value)
|
|||
Py_DECREF(o);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
PyModule_AddType(PyObject *module, PyTypeObject *type)
|
||||
{
|
||||
if (PyType_Ready(type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *name = _PyType_Name(type);
|
||||
assert(name != NULL);
|
||||
|
||||
Py_INCREF(type);
|
||||
if (PyModule_AddObject(module, name, (PyObject *)type) < 0) {
|
||||
Py_DECREF(type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue