[glom] libglom_init(): Show the python exception when PyDateTime_IMPORT fails.



commit 0a70e324ef7f365e4442c7bb1a8a73dba9cde309
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Mar 14 06:46:39 2011 +0100

    libglom_init(): Show the python exception when PyDateTime_IMPORT fails.
    
    * glom/libglom/init.cc: The linker seems to behave differently when this
    code is run from inside a JVM in OnlineGlom. This gives us a clue.

 ChangeLog            |    7 +++++++
 glom/libglom/init.cc |    9 +++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a52d047..0d159a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-03-14  Murray Cumming  <murrayc murrayc com>
+
+	libglom_init(): Show the python exception when PyDateTime_IMPORT fails.
+
+	* glom/libglom/init.cc: The linker seems to behave differently when this 
+	code is run from inside a JVM in OnlineGlom. This gives us a clue.
+
 2011-03-12  Murray Cumming  <murrayc murrayc com>
 
 	Fix crashes when using choices with fixed lists.
diff --git a/glom/libglom/init.cc b/glom/libglom/init.cc
index 97a813e..f9e8e6c 100644
--- a/glom/libglom/init.cc
+++ b/glom/libglom/init.cc
@@ -48,6 +48,15 @@ void libglom_init()
 
   Py_Initialize();
   PyDateTime_IMPORT; //A macro, needed to use PyDate_Check(), PyDateTime_Check(), etc.
+  if(!PyDateTimeAPI)
+  {
+    //Give people a clue on stdout:
+    std::cerr << G_STRFUNC << ": PyDateTime_IMPORT (a python module import) failed." << std::endl; 
+    
+    //This gives more information. When this happens it is generally a linker 
+    //failure while importing a python module:
+    PyErr_Print();
+  }
   g_assert(PyDateTimeAPI); //This should have been set by the PyDateTime_IMPORT macro.
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]