UI: errors in buttons now show in info report

Mistakes in button expressions were previously only printed to the console.
This commit is contained in:
2015-05-18 09:12:26 +10:00
parent 3ed009af96
commit 29aae4db38
8 changed files with 85 additions and 27 deletions

View File

@@ -478,6 +478,34 @@ error_cleanup:
}
#endif
PyObject *PyC_ExceptionBuffer_Simple(void)
{
PyObject *string_io_buf;
PyObject *error_type, *error_value, *error_traceback;
if (!PyErr_Occurred())
return NULL;
PyErr_Fetch(&error_type, &error_value, &error_traceback);
if (error_value == NULL) {
return NULL;
}
string_io_buf = PyObject_Str(error_value);
/* Python does this too */
if (UNLIKELY(string_io_buf == NULL)) {
string_io_buf = PyUnicode_FromFormat(
"<unprintable %s object>", Py_TYPE(error_value)->tp_name);
}
PyErr_Restore(error_type, error_value, error_traceback);
PyErr_Print();
PyErr_Clear();
return string_io_buf;
}
/* string conversion, escape non-unicode chars, coerce must be set to NULL */
const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce)