diff options
author | Steve Dower <steve.dower@microsoft.com> | 2019-01-25 22:59:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-25 22:59:58 (GMT) |
commit | adad9e68013aac166c84ffe4e23f3a5464f41840 (patch) | |
tree | 0fbd69baff9c1eb60a6f63f5fa4b499fb27b4f73 /PC | |
parent | 4e02f8f8b4baab63f927cfd87b401200ba2969e9 (diff) | |
download | cpython-adad9e68013aac166c84ffe4e23f3a5464f41840.zip cpython-adad9e68013aac166c84ffe4e23f3a5464f41840.tar.gz cpython-adad9e68013aac166c84ffe4e23f3a5464f41840.tar.bz2 |
bpo-35811: Avoid propagating venv settings when launching via py.exe (GH-11677)
Diffstat (limited to 'PC')
-rw-r--r-- | PC/launcher.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/PC/launcher.c b/PC/launcher.c index 4c620da..a78620a 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1707,6 +1707,17 @@ process(int argc, wchar_t ** argv) command = skip_me(GetCommandLineW()); debug(L"Called with command line: %ls\n", command); +#if !defined(VENV_REDIRECT) + /* bpo-35811: The __PYVENV_LAUNCHER__ variable is used to + * override sys.executable and locate the original prefix path. + * However, if it is silently inherited by a non-venv Python + * process, that process will believe it is running in the venv + * still. This is the only place where *we* can clear it (that is, + * when py.exe is being used to launch Python), so we do. + */ + SetEnvironmentVariableW(L"__PYVENV_LAUNCHER__", NULL); +#endif + #if defined(SCRIPT_WRAPPER) /* The launcher is being used in "script wrapper" mode. * There should therefore be a Python script named <exename>-script.py in |