Skip to content

Commit

Permalink
Should included python fail at least output trace to yast log
Browse files Browse the repository at this point in the history
  • Loading branch information
noelpower authored and dmulder committed Jan 18, 2019
1 parent efe6282 commit 6f591c4
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/YPython.cc
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,29 @@ string YPython::PyErrorHandler()
(pystring = PyObject_Str(errtraceback)) != NULL &&
(PyString_Check(pystring))
) {
result += PyString_AsString(pystring);
PyObject *mod = PyImport_ImportModule("traceback");
if (mod) {
PyObject *traceStr = NULL;
PyObject *newline = PyUnicode_FromString("\n");
PyObject * meth_result =
PyObject_CallMethod(mod,
"format_exception",
"(OOO)",
errobj,
errdata,
errtraceback);
if (meth_result) {
traceStr = PyUnicode_Join(newline, meth_result);
}
if (traceStr) {
result += PyString_AsString(traceStr);
}
Py_XDECREF(meth_result);
Py_XDECREF(traceStr);
Py_XDECREF(newline);
} else {
result += PyString_AsString(pystring);
}
} else {
result += "<unknown exception traceback>";
}
Expand Down

0 comments on commit 6f591c4

Please sign in to comment.