From 93025ef23657d842009c9c73c721fb9092ea382e Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Tue, 13 Apr 2021 20:12:10 +0200 Subject: [PATCH] env: do not modify os.environ Replace updates of os.environ with explicit passing of `env` to subprocess calls in `Env.execute()`. Relates-to: #3199 --- poetry/utils/env.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/poetry/utils/env.py b/poetry/utils/env.py index f8ed6ab0286..899ff20ec92 100644 --- a/poetry/utils/env.py +++ b/poetry/utils/env.py @@ -1245,6 +1245,7 @@ def _run(self, cmd: List[str], **kwargs: Any) -> Union[int, str]: """ call = kwargs.pop("call", False) input_ = kwargs.pop("input_", None) + env = kwargs.pop("env", {k: v for k, v in os.environ.items()}) try: if self._is_windows: @@ -1263,10 +1264,10 @@ def _run(self, cmd: List[str], **kwargs: Any) -> Union[int, str]: **kwargs, ).stdout elif call: - return subprocess.call(cmd, stderr=subprocess.STDOUT, **kwargs) + return subprocess.call(cmd, stderr=subprocess.STDOUT, env=env, **kwargs) else: output = subprocess.check_output( - cmd, stderr=subprocess.STDOUT, **kwargs + cmd, stderr=subprocess.STDOUT, env=env, **kwargs ) except CalledProcessError as e: raise EnvCommandError(e, input=input_)