summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/sysmodule.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index d87b4e2c01..942a8b6bec 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2448,8 +2448,6 @@ err_occurred:
return _Py_INIT_ERR("can't initialize sys module");
}
-#undef SET_SYS_FROM_STRING
-
/* Updating the sys namespace, returning integer error codes */
#define SET_SYS_FROM_STRING_INT_RESULT(key, value) \
do { \
@@ -2483,6 +2481,17 @@ _PySys_EndInit(PyObject *sysdict, _PyMainInterpreterConfig *config)
SET_SYS_FROM_STRING_BORROW("exec_prefix", config->exec_prefix);
SET_SYS_FROM_STRING_BORROW("base_exec_prefix", config->base_exec_prefix);
+#ifdef MS_WINDOWS
+ const wchar_t *baseExecutable = _wgetenv(L"__PYVENV_BASE_EXECUTABLE__");
+ if (baseExecutable) {
+ SET_SYS_FROM_STRING("_base_executable",
+ PyUnicode_FromWideChar(baseExecutable, -1));
+ _wputenv_s(L"__PYVENV_BASE_EXECUTABLE__", L"");
+ } else {
+ SET_SYS_FROM_STRING_BORROW("_base_executable", config->executable);
+ }
+#endif
+
if (config->argv != NULL) {
SET_SYS_FROM_STRING_BORROW("argv", config->argv);
}
@@ -2528,6 +2537,7 @@ err_occurred:
return -1;
}
+#undef SET_SYS_FROM_STRING
#undef SET_SYS_FROM_STRING_BORROW
#undef SET_SYS_FROM_STRING_INT_RESULT