[Bf-blender-cvs] [276d19f63b4] blender-v2.91-release: PyAPI: set sys.executable to None when Python can't be found

Campbell Barton noreply at git.blender.org
Sun Nov 1 08:20:34 CET 2020


Commit: 276d19f63b4534545c2e1a9d5c48525298b1a445
Author: Campbell Barton
Date:   Sun Nov 1 18:12:26 2020 +1100
Branches: blender-v2.91-release
https://developer.blender.org/rB276d19f63b4534545c2e1a9d5c48525298b1a445

PyAPI: set sys.executable to None when Python can't be found

Without this, sys.executable may be set to Blender's
executable instead.

===================================================================

M	source/blender/python/intern/bpy_interface.c

===================================================================

diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index a4417f38756..d72c2ccfcff 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -361,17 +361,19 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
   /* Setting the program name is important so the 'multiprocessing' module
    * can launch new Python instances. */
   {
+    const char *sys_variable = "executable";
     char program_path[FILE_MAX];
     if (BKE_appdir_program_python_search(
             program_path, sizeof(program_path), PY_MAJOR_VERSION, PY_MINOR_VERSION)) {
       PyObject *py_program_path = PyC_UnicodeFromByte(program_path);
-      PySys_SetObject("executable", py_program_path);
+      PySys_SetObject(sys_variable, py_program_path);
       Py_DECREF(py_program_path);
     }
     else {
       fprintf(stderr,
               "Unable to find the python binary, "
               "the multiprocessing module may not be functional!\n");
+      PySys_SetObject(sys_variable, Py_None);
     }
   }



More information about the Bf-blender-cvs mailing list