summaryrefslogtreecommitdiff
path: root/PC
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-01-25 15:31:18 -0800
committerGitHub <noreply@github.com>2019-01-25 15:31:18 -0800
commita6a8524bb1c78c7425346ec20ecffc02d1d02a79 (patch)
tree686e2b42d54451e34563fd0a1ed32cd1f9826914 /PC
parent6a9c0fca3f2f93681468b51929472f4433753f25 (diff)
downloadcpython-git-a6a8524bb1c78c7425346ec20ecffc02d1d02a79.tar.gz
bpo-35811: Avoid propagating venv settings when launching via py.exe (GH-11677)
(cherry picked from commit adad9e68013aac166c84ffe4e23f3a5464f41840) Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Diffstat (limited to 'PC')
-rw-r--r--PC/launcher.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/PC/launcher.c b/PC/launcher.c
index 4c620dab7c..a78620a892 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