From 7eb84ebd9039654f512fd27b535fd4e305bcb46d Mon Sep 17 00:00:00 2001 From: Sean Kim Date: Tue, 16 Sep 2025 14:34:14 +0200 Subject: [PATCH] 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 --- source/blender/python/intern/bpy_rna.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/python/intern/bpy_rna.cc b/source/blender/python/intern/bpy_rna.cc index 85f3342dc72..e07b2bd7c9c 100644 --- a/source/blender/python/intern/bpy_rna.cc +++ b/source/blender/python/intern/bpy_rna.cc @@ -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);