mirror of https://github.com/Icinga/icinga2.git
Fix PythonLanguage::ExceptionInfoToString().
This commit is contained in:
parent
efb62f4b5c
commit
c1a98d66be
|
@ -105,7 +105,7 @@ void PythonInterpreter::ProcessCall(const ScriptTask::Ptr& task, const String& f
|
|||
Py_XDECREF(pvalue);
|
||||
Py_XDECREF(ptraceback);
|
||||
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Error in Python script:" + msg));
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Error in Python script: " + msg));
|
||||
}
|
||||
|
||||
Value vresult = PythonLanguage::MarshalFromPython(result);
|
||||
|
|
|
@ -225,13 +225,25 @@ String PythonLanguage::ExceptionInfoToString(PyObject *type, PyObject *exc, PyOb
|
|||
Py_DECREF(format_exception);
|
||||
Py_DECREF(tb_dict);
|
||||
|
||||
if (!result || !PyString_Check(result)) {
|
||||
if (!result || !PyList_Check(result)) {
|
||||
Py_XDECREF(result);
|
||||
|
||||
return "format_exception() returned something that is not a string.";
|
||||
return "format_exception() returned something that is not a list.";
|
||||
}
|
||||
|
||||
String msg = PyString_AsString(result);
|
||||
String msg;
|
||||
|
||||
for (Py_ssize_t i = 0; i < PyList_Size(result); i++) {
|
||||
PyObject *li = PyList_GetItem(result, i);
|
||||
|
||||
if (!li || !PyString_Check(li)) {
|
||||
Py_DECREF(result);
|
||||
|
||||
return "format_exception() returned something that is not a list of strings.";
|
||||
}
|
||||
|
||||
msg += PyString_AsString(li);
|
||||
}
|
||||
|
||||
Py_DECREF(result);
|
||||
|
||||
|
|
Loading…
Reference in New Issue