diff options
| author | Brandt Bucher <brandtbucher@gmail.com> | 2019-09-12 05:11:20 -0700 |
|---|---|---|
| committer | Stéphane Wirtel <stephane@wirtel.be> | 2019-09-12 13:11:20 +0100 |
| commit | 224b8aaa7e8f67f748e8b7b6a4a77a25f6554651 (patch) | |
| tree | 209bec1d2dd42b404f13c42c3c8e98988908a863 /Doc/includes/custom2.c | |
| parent | 967b84c913c7b09ae2fc86272cb9373415e2beaf (diff) | |
| download | cpython-git-224b8aaa7e8f67f748e8b7b6a4a77a25f6554651.tar.gz | |
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/custom2.c')
| -rw-r--r-- | Doc/includes/custom2.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Doc/includes/custom2.c b/Doc/includes/custom2.c index 6477a19daf..5bacab7a2a 100644 --- a/Doc/includes/custom2.c +++ b/Doc/includes/custom2.c @@ -128,6 +128,11 @@ PyInit_custom2(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; } |
