Python: Copy the environment when launching the upload process

The previous fix set the `PYTHONPATH` for the subprocess.
That overwrites the complete environment, clearing out any other
variables.
That can cause problems when other parts rely on something, such as the
RNG in Python relying on `SYSTEMROOT`
This commit is contained in:
Jan-Erik Rediger 2021-12-15 10:31:27 +01:00
Родитель 581f57ba3b
Коммит b44f9f7c0c
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -123,11 +123,15 @@ class ProcessDispatcher:
# Explicitly pass the contents of `sys.path` as `PYTHONPATH` to the
# subprocess so that there aren't any module search path
# differences.
python_path = ":".join(sys.path)[1:]
python_path = ":".join(sys.path)
# We re-use the existing environment and overwrite only the `PYTHONPATH`
env = os.environ.copy()
env["PYTHONPATH"] = python_path
p = subprocess.Popen(
[sys.executable, _process_dispatcher_helper.__file__, payload],
env={"PYTHONPATH": python_path},
env=env,
)
cls._last_process = p