Giving at least some error information when a Python exception happens during command...
authorEnrico Granata <egranata@apple.com>
Tue, 13 Nov 2012 02:57:43 +0000 (02:57 +0000)
committerEnrico Granata <egranata@apple.com>
Tue, 13 Nov 2012 02:57:43 +0000 (02:57 +0000)
llvm-svn: 167810

lldb/source/Interpreter/ScriptInterpreterPython.cpp

index 11a64b6..638720e 100644 (file)
@@ -2483,7 +2483,17 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname,
                 }
                 else // any other error
                 {
-                    error.SetErrorString("Python raised an error while importing module");
+                    PyObject *type,*value,*traceback;
+                    PyErr_Fetch (&type,&value,&traceback);
+                    
+                    if (value && value != Py_None)
+                        error.SetErrorStringWithFormat("Python error raised while importing module: %s", PyString_AsString(PyObject_Str(value)));
+                    else
+                        error.SetErrorString("Python raised an error while importing module");
+                    
+                    Py_XDECREF(type);
+                    Py_XDECREF(value);
+                    Py_XDECREF(traceback);
                 }
             }
             else // we failed but have no error to explain why