diff options
Diffstat (limited to 'Doc/extending/extending.rst')
-rw-r--r-- | Doc/extending/extending.rst | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst index 0c5da49..00a9edc 100644 --- a/Doc/extending/extending.rst +++ b/Doc/extending/extending.rst @@ -221,9 +221,7 @@ with an exception object:: return NULL; SpamError = PyErr_NewException("spam.error", NULL, NULL); - Py_XINCREF(SpamError); - if (PyModule_AddObject(m, "error", SpamError) < 0) { - Py_XDECREF(SpamError); + if (PyModule_AddObjectRef(m, "error", SpamError) < 0) { Py_CLEAR(SpamError); Py_DECREF(m); return NULL; @@ -1281,8 +1279,7 @@ function must take care of initializing the C API pointer array:: /* Create a Capsule containing the API pointer array's address */ c_api_object = PyCapsule_New((void *)PySpam_API, "spam._C_API", NULL); - if (PyModule_AddObject(m, "_C_API", c_api_object) < 0) { - Py_XDECREF(c_api_object); + if (PyModule_Add(m, "_C_API", c_api_object) < 0) { Py_DECREF(m); return NULL; } |