Skip to content

Commit eef07aa

Browse files
committed
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
1 parent f168658 commit eef07aa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

poetry/utils/env.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,7 @@ def _run(self, cmd: List[str], **kwargs: Any) -> Union[int, str]:
12481248
"""
12491249
call = kwargs.pop("call", False)
12501250
input_ = kwargs.pop("input_", None)
1251+
env = kwargs.pop("env", {k: v for k, v in os.environ.items()})
12511252

12521253
try:
12531254
if self._is_windows:
@@ -1266,10 +1267,10 @@ def _run(self, cmd: List[str], **kwargs: Any) -> Union[int, str]:
12661267
**kwargs,
12671268
).stdout
12681269
elif call:
1269-
return subprocess.call(cmd, stderr=subprocess.STDOUT, **kwargs)
1270+
return subprocess.call(cmd, stderr=subprocess.STDOUT, env=env, **kwargs)
12701271
else:
12711272
output = subprocess.check_output(
1272-
cmd, stderr=subprocess.STDOUT, **kwargs
1273+
cmd, stderr=subprocess.STDOUT, env=env, **kwargs
12731274
)
12741275
except CalledProcessError as e:
12751276
raise EnvCommandError(e, input=input_)

0 commit comments

Comments
 (0)