Fix PythonLanguage::ExceptionInfoToString().

This commit is contained in:
Gunnar Beutner 2013-02-16 12:47:52 +01:00
parent efb62f4b5c
commit c1a98d66be
2 changed files with 16 additions and 4 deletions

View File

@ -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);

View File

@ -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);