Cleanup: move Python's GIL ensure/release to the function start/end

Avoid errors accessing state without the GIL (#127767) by moving
GIL ensure/release to the star/end of the function body.
This commit is contained in:
Campbell Barton
2025-02-13 17:56:42 +11:00
parent 886e40f136
commit e52f85b33c
10 changed files with 40 additions and 62 deletions

View File

@@ -62,10 +62,11 @@ static int bpy_cli_command_exec(bContext *C,
const int argc,
const char **argv)
{
int exit_code = EXIT_FAILURE;
PyGILState_STATE gilstate;
bpy_context_set(C, &gilstate);
int exit_code = EXIT_FAILURE;
/* For the most part `sys.argv[-argc:]` is sufficient & less trouble than re-creating this
* list. Don't do this because:
* - Python scripts *could* have manipulated `sys.argv` (although it's bad practice).