diff options
author | Brandt Bucher <brandtbucher@gmail.com> | 2019-09-12 12:11:20 (GMT) |
---|---|---|
committer | Stéphane Wirtel <stephane@wirtel.be> | 2019-09-12 12:11:20 (GMT) |
commit | 224b8aaa7e8f67f748e8b7b6a4a77a25f6554651 (patch) | |
tree | 209bec1d2dd42b404f13c42c3c8e98988908a863 /Doc/includes/custom4.c | |
parent | 967b84c913c7b09ae2fc86272cb9373415e2beaf (diff) | |
download | cpython-224b8aaa7e8f67f748e8b7b6a4a77a25f6554651.zip cpython-224b8aaa7e8f67f748e8b7b6a4a77a25f6554651.tar.gz cpython-224b8aaa7e8f67f748e8b7b6a4a77a25f6554651.tar.bz2 |
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
Diffstat (limited to 'Doc/includes/custom4.c')
-rw-r--r-- | Doc/includes/custom4.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Doc/includes/custom4.c b/Doc/includes/custom4.c index b0b2906..584992f 100644 --- a/Doc/includes/custom4.c +++ b/Doc/includes/custom4.c @@ -193,6 +193,11 @@ PyInit_custom4(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; } |