diff options
author | Steve Dower <steve.dower@python.org> | 2019-06-28 10:02:13 -0700 |
---|---|---|
committer | Ned Deily <nad@python.org> | 2019-07-01 22:24:26 -0400 |
commit | 3c34ea97a341e4dd80b542c99c593f014a8ae410 (patch) | |
tree | 0c65fde80bdd1fb2fe7f9613cada893d15bfd180 /Python/sysmodule.c | |
parent | cc0bf97d61fbe844843f28abc510a11f3ef09942 (diff) | |
download | cpython-git-3c34ea97a341e4dd80b542c99c593f014a8ae410.tar.gz |
bpo-37369: Fixes path for sys.executable when running from the Microsoft Store (GH-14450)
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 14 |
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 |