From 67ec866ca46bdd9950d5ce24bc7f45c305e57321 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 26 Jun 2014 22:31:49 +0000 Subject: NO-JIRA: Error handling in swig_python_typemaps: don't core dump if qpid.datatypes is not found. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1605920 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/include/qpid/swig_python_typemaps.i | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'qpid/cpp') diff --git a/qpid/cpp/include/qpid/swig_python_typemaps.i b/qpid/cpp/include/qpid/swig_python_typemaps.i index e9a84ffa8e..0fc4d9019f 100644 --- a/qpid/cpp/include/qpid/swig_python_typemaps.i +++ b/qpid/cpp/include/qpid/swig_python_typemaps.i @@ -30,13 +30,16 @@ static PyObject* pUuidModule; * qpid.datatypes. */ pUuidModule = PyImport_ImportModule("qpid.datatypes"); - - /* Although it is not required, we'll publish the uuid module in our - * module, as if this module was a python module and we called - * "import uuid" - */ - Py_INCREF(pUuidModule); - PyModule_AddObject(m, "uuid", pUuidModule); + if (pUuidModule) { + /* Although it is not required, we'll publish the uuid module in our + * module, as if this module was a python module and we called + * "import uuid" + */ + Py_INCREF(pUuidModule); + PyModule_AddObject(m, "uuid", pUuidModule); + } else { + if (!PyErr_Occurred) PyErr_SetString(PyExc_ImportError, "Cannot import qpid.datatypes"); + } %} @@ -101,7 +104,7 @@ typedef int Py_ssize_t; result = PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) v->asUint64()); break; } - case qpid::types::VAR_INT8 : + case qpid::types::VAR_INT8 : case qpid::types::VAR_INT16 : case qpid::types::VAR_INT32 : { result = PyInt_FromLong((long) v->asInt32()); -- cgit v1.2.1