mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-26868: Fix example usage of PyModule_AddObject. (#15725)
* Add a note to the PyModule_AddObject docs. * Correct example usages of PyModule_AddObject. * Whitespace. * Clean up wording. * 📜🤖 Added by blurb_it. * First code review. * Add < 0 in the tests with PyModule_AddObject
This commit is contained in:
parent
967b84c913
commit
224b8aaa7e
9 changed files with 74 additions and 13 deletions
|
@ -35,6 +35,11 @@ PyInit_custom(void)
|
|||
return NULL;
|
||||
|
||||
Py_INCREF(&CustomType);
|
||||
PyModule_AddObject(m, "Custom", (PyObject *) &CustomType);
|
||||
if (PyModule_AddObject(m, "Custom", (PyObject *) &CustomType) < 0) {
|
||||
Py_DECREF(&CustomType);
|
||||
PY_DECREF(m);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue