summaryrefslogtreecommitdiff
path: root/Lib/site.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/site.py')
-rw-r--r--Lib/site.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/site.py b/Lib/site.py
index ffd132b389..ad1146332b 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -457,7 +457,14 @@ def venv(known_paths):
env = os.environ
if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in env:
- executable = os.environ['__PYVENV_LAUNCHER__']
+ executable = sys._base_executable = os.environ['__PYVENV_LAUNCHER__']
+ elif sys.platform == 'win32' and '__PYVENV_LAUNCHER__' in env:
+ executable = sys.executable
+ import _winapi
+ sys._base_executable = _winapi.GetModuleFileName(0)
+ # bpo-35873: Clear the environment variable to avoid it being
+ # inherited by child processes.
+ del os.environ['__PYVENV_LAUNCHER__']
else:
executable = sys.executable
exe_dir, _ = os.path.split(os.path.abspath(executable))