in Python console check if exception is dict and set more readable text

This commit is contained in:
wmayer
2017-05-17 19:37:34 +02:00
parent b1e3777834
commit f3e722c6de

View File

@@ -320,8 +320,20 @@ void InteractiveInterpreter::runCode(PyCodeObject* code) const
// throw SystemExit exception
throw Base::SystemExitException();
}
if ( PyErr_Occurred() ) /* get latest python exception information */
if (PyErr_Occurred()) { /* get latest python exception information */
PyObject *errobj, *errdata, *errtraceback;
PyErr_Fetch(&errobj, &errdata, &errtraceback);
if (PyDict_Check(errdata)) {
PyObject* value = PyDict_GetItemString(errdata, "swhat");
if (value) {
Py_INCREF(value);
Py_DECREF(errdata);
errdata = value;
}
}
PyErr_Restore(errobj, errdata, errtraceback);
PyErr_Print(); /* and print the error to the error output */
}
} else {
Py_DECREF(presult);
}