From 8c1572369a64464158c274730e6142b78508354f Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Thu, 20 Sep 2012 11:32:48 -0500 Subject: [PATCH] try to return exception information when numpy fails to import --- src/plang/Invocation.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plang/Invocation.cpp b/src/plang/Invocation.cpp index b07f781bb9..4a5ff8b50b 100644 --- a/src/plang/Invocation.cpp +++ b/src/plang/Invocation.cpp @@ -61,7 +61,12 @@ void Invocation::numpy_init() // this macro is defined be NumPy and must be included if (_import_array() < 0) { - throw python_error("unable to initialize NumPy"); + PyObject *ptype, *pvalue, *ptraceback; + PyErr_Fetch(&ptype, &pvalue, &ptraceback); + char *message = PyString_AsString(pvalue); + std::ostringstream oss; + oss << "unable to initialize NumPy with error '" << std::string(message) << "'"; + throw python_error(oss.str()); } }