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 | |
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')
-rw-r--r-- | Doc/includes/custom.c | 7 | ||||
-rw-r--r-- | Doc/includes/custom2.c | 7 | ||||
-rw-r--r-- | Doc/includes/custom3.c | 7 | ||||
-rw-r--r-- | Doc/includes/custom4.c | 7 | ||||
-rw-r--r-- | Doc/includes/sublist.c | 7 |
5 files changed, 30 insertions, 5 deletions
diff --git a/Doc/includes/custom.c b/Doc/includes/custom.c index 13d16f5..bda32e2 100644 --- a/Doc/includes/custom.c +++ b/Doc/includes/custom.c @@ -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; } diff --git a/Doc/includes/custom2.c b/Doc/includes/custom2.c index 6477a19..5bacab7 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; } diff --git a/Doc/includes/custom3.c b/Doc/includes/custom3.c index 213d086..2b7a99e 100644 --- a/Doc/includes/custom3.c +++ b/Doc/includes/custom3.c @@ -179,6 +179,11 @@ PyInit_custom3(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; } 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; } diff --git a/Doc/includes/sublist.c b/Doc/includes/sublist.c index 76ff939..b2c26e7 100644 --- a/Doc/includes/sublist.c +++ b/Doc/includes/sublist.c @@ -59,6 +59,11 @@ PyInit_sublist(void) return NULL; Py_INCREF(&SubListType); - PyModule_AddObject(m, "SubList", (PyObject *) &SubListType); + if (PyModule_AddObject(m, "SubList", (PyObject *) &SubListType) < 0) { + Py_DECREF(&SubListType); + Py_DECREF(m); + return NULL; + } + return m; } |