diff options
author | Steve Dower <steve.dower@microsoft.com> | 2019-02-04 07:19:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-04 07:19:38 (GMT) |
commit | a8474d025cab794257d2fd0bea67840779b9351f (patch) | |
tree | 1e2521303b70f42bd63cf1f432513db9cfd04742 /Lib/site.py | |
parent | 2f6fae6e510dba653391cb510a2aca8322eec03b (diff) | |
download | cpython-a8474d025cab794257d2fd0bea67840779b9351f.zip cpython-a8474d025cab794257d2fd0bea67840779b9351f.tar.gz cpython-a8474d025cab794257d2fd0bea67840779b9351f.tar.bz2 |
bpo-35872 and bpo-35873: Clears __PYVENV_LAUNCHER__ variable (GH-11745)
After reading __PYVENV_LAUNCHER__ we now set sys._base_executable value for later use.
Make the same changes for macOS to avoid extra platform checks.
Diffstat (limited to 'Lib/site.py')
-rw-r--r-- | Lib/site.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/site.py b/Lib/site.py index ffd132b..ad11463 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)) |