Python: flush stdout and stderr after running Python script
When debugging with gdb in vscode, the stuff I print when executing a script in the text editor does not show up in the terminal. It does work when I flush explicitly though using `print(..., flush=True)`. This is quite annoying. The solution is to always flush `stdout` and `stderr` automatically when running a script. This is done using the CPython API, as just using `fflush(stdout/stderr)` did not solve the issue. Pull Request: https://projects.blender.org/blender/blender/pulls/136632
This commit is contained in:
@@ -217,6 +217,10 @@ static bool python_script_exec(
|
||||
|
||||
PyC_MainModule_Restore(main_mod);
|
||||
|
||||
/* Flush stdout/stderr to ensure the script output is visible.
|
||||
* Using fflush(stdout) does not solve it. */
|
||||
PyC_StdFilesFlush();
|
||||
|
||||
bpy_context_clear(C, &gilstate);
|
||||
|
||||
return (py_result != nullptr);
|
||||
|
||||
Reference in New Issue
Block a user