Merge pull request #857 from pypeclub/bugfix/env_change_on_app_launch

Create dict copy of environments on application launch
This commit is contained in:
Milan Kolar 2020-12-22 17:16:06 +01:00 committed by GitHub
commit 5806713004
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,4 @@
import os
import copy
import platform
import inspect
import subprocess
@ -531,15 +530,23 @@ class ApplicationLaunchContext:
self.launch_args = executable.as_args()
# Handle launch environemtns
passed_env = self.data.pop("env", None)
if passed_env is None:
env = self.data.pop("env", None)
if env is not None and not isinstance(env, dict):
self.log.warning((
"Passed `env` kwarg has invalid type: {}. Expected: `dict`."
" Using `os.environ` instead."
).format(str(type(env))))
env = None
if env is None:
env = os.environ
else:
env = passed_env
# subprocess.Popen keyword arguments
self.kwargs = {
"env": copy.deepcopy(env)
"env": {
key: str(value)
for key, value in env.items()
}
}
if platform.system().lower() == "windows":