bpo-35811: Avoid propagating venv settings when launching via py.exe (GH-11677)

This commit is contained in:
Steve Dower 2019-01-25 14:59:58 -08:00 committed by GitHub
parent 4e02f8f8b4
commit adad9e6801
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1 @@
Avoid propagating venv settings when launching via py.exe

View file

@ -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