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:
Brandt Bucher 2019-09-12 05:11:20 -07:00 committed by Stéphane Wirtel
parent 967b84c913
commit 224b8aaa7e
9 changed files with 74 additions and 13 deletions

View file

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