diff options
author | Steve Dower <steve.dower@microsoft.com> | 2019-01-25 22:59:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-25 22:59:12 (GMT) |
commit | 4e02f8f8b4baab63f927cfd87b401200ba2969e9 (patch) | |
tree | f3a946b168fc3c72b7b6afda4a164b2d008e096b /Lib/multiprocessing/spawn.py | |
parent | 3bab40db96efda2e127ef84e6501fda0cdc4f5b8 (diff) | |
download | cpython-4e02f8f8b4baab63f927cfd87b401200ba2969e9.zip cpython-4e02f8f8b4baab63f927cfd87b401200ba2969e9.tar.gz cpython-4e02f8f8b4baab63f927cfd87b401200ba2969e9.tar.bz2 |
bpo-35797: Fix default executable used by the multiprocessing module (GH-11676)
Diffstat (limited to 'Lib/multiprocessing/spawn.py')
-rw-r--r-- | Lib/multiprocessing/spawn.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/multiprocessing/spawn.py b/Lib/multiprocessing/spawn.py index 73aa694..860fa4c 100644 --- a/Lib/multiprocessing/spawn.py +++ b/Lib/multiprocessing/spawn.py @@ -29,12 +29,19 @@ __all__ = ['_main', 'freeze_support', 'set_executable', 'get_executable', if sys.platform != 'win32': WINEXE = False WINSERVICE = False + _WINENV = False else: - WINEXE = (sys.platform == 'win32' and getattr(sys, 'frozen', False)) + WINEXE = getattr(sys, 'frozen', False) WINSERVICE = sys.executable.lower().endswith("pythonservice.exe") + _WINENV = '__PYVENV_LAUNCHER__' in os.environ if WINSERVICE: _python_exe = os.path.join(sys.exec_prefix, 'python.exe') +elif _WINENV: + # bpo-35797: When running in a venv, we need to bypass the redirect + # executor and launch our base Python. + import _winapi + _python_exe = _winapi.GetModuleFileName(0) else: _python_exe = sys.executable |