Python: Print script errors with CLOG

Currently, when a python error is encountered when rendering the UI, the
corresponding message is printed to stdout / stderr via `PyErr_Print`,
this patch modifies behavior so that a cursory message is also printed
with CLOG

This has the benefit of allowing for testing via
`--debug-exit-on-error`, which aborts Blender when an error message is
printed.

Pull Request: https://projects.blender.org/blender/blender/pulls/146296
This commit is contained in:
Sean Kim
2025-09-16 14:34:14 +02:00
committed by Sean Kim
parent 0a1b7ca067
commit 7eb84ebd90

View File

@@ -9835,6 +9835,13 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
/* Also print in the console for Python. */
PyErr_Print();
/* Print a small line at ERROR level so that tests that rely on --debug-exit-on-error can
* fail. This assumes that the majority of the information is already seen in the console via
* PyErr_Print and should not be duplicated */
CLOG_ERROR(BPY_LOG_RNA,
"Python script error in %.200s.%.200s",
RNA_struct_identifier(ptr->type),
RNA_function_identifier(func));
}
bpy_context_clear(C, &gilstate);