From: Jesus Cea Date: Fri, 5 Nov 2010 00:13:50 +0000 (+0000) Subject: Issue #9675: better error handling in bsddb X-Git-Tag: v2.7.1rc1~55 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=84f2c325c3b0acfc3d174ce0f6c75e50fc8a8e0e;p=thirdparty%2FPython%2Fcpython.git Issue #9675: better error handling in bsddb --- diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index 5266a2cfced0..14517764e5ef 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -9976,8 +9976,21 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */ } #endif - PyDict_SetItemString(d, "api", py_api); - Py_DECREF(py_api); + /* Check error control */ + /* + ** PyErr_NoMemory(); + ** py_api = NULL; + */ + + if (py_api) { + PyDict_SetItemString(d, "api", py_api); + Py_DECREF(py_api); + } else { /* Something bad happened */ + PyErr_WriteUnraisable(m); + PyErr_Warn(PyExc_RuntimeWarning, + "_bsddb/_pybsddb C API will be not available"); + PyErr_Clear(); + } /* Check for errors */ if (PyErr_Occurred()) {