Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/BPY_extern.h1
-rw-r--r--source/blender/python/intern/bpy_interface.c13
2 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index be2fd6c4e53..810c86c115a 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -51,6 +51,7 @@ int BPY_is_pyconstraint(struct Text *text);
void BPY_python_start(int argc, const char **argv);
void BPY_python_end(void);
void BPY_python_reset(struct bContext *C);
+void BPY_python_use_system_env(void);
/* global interpreter lock */
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 9acf05abfe2..28afab1a6eb 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -84,6 +84,9 @@ CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_RNA, "bpy.rna");
* stop bpy_context_clear from invalidating. */
static int py_call_level = 0;
+/* Set by command line arguments before Python starts. */
+static bool py_use_system_env = false;
+
// #define TIME_PY_RUN // simple python tests. prints on exit.
#ifdef TIME_PY_RUN
@@ -276,6 +279,10 @@ void BPY_python_start(int argc, const char **argv)
* While harmless, it's noisy. */
Py_FrozenFlag = 1;
+ /* Only use the systems environment variables when explicitly requested.
+ * Since an incorrect 'PYTHONPATH' causes difficult to debug errors, see: T72807. */
+ Py_IgnoreEnvironmentFlag = !py_use_system_env;
+
Py_Initialize();
// PySys_SetArgv(argc, argv); /* broken in py3, not a huge deal */
@@ -408,6 +415,12 @@ void BPY_python_reset(bContext *C)
BPY_modules_load_user(C);
}
+void BPY_python_use_system_env(void)
+{
+ BLI_assert(!Py_IsInitialized());
+ py_use_system_env = true;
+}
+
static void python_script_error_jump_text(struct Text *text)
{
int lineno;