Author: aconway
Date: Thu Jun 26 22:31:49 2014
New Revision: 1605920

URL: http://svn.apache.org/r1605920
Log:
NO-JIRA: Error handling in swig_python_typemaps: don't core dump if 
qpid.datatypes is not found.

Modified:
    qpid/trunk/qpid/cpp/include/qpid/swig_python_typemaps.i

Modified: qpid/trunk/qpid/cpp/include/qpid/swig_python_typemaps.i
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/swig_python_typemaps.i?rev=1605920&r1=1605919&r2=1605920&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/swig_python_typemaps.i (original)
+++ qpid/trunk/qpid/cpp/include/qpid/swig_python_typemaps.i Thu Jun 26 22:31:49 
2014
@@ -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());



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to