From a4de80a61eccb84e437b3ee3e792221a491f27db Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 22 Dec 2020 15:41:31 +0100 Subject: [PATCH 1/3] call `.copy()` on variable env --- pype/lib/applications.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pype/lib/applications.py b/pype/lib/applications.py index c7d6464418..ce49eed961 100644 --- a/pype/lib/applications.py +++ b/pype/lib/applications.py @@ -531,15 +531,13 @@ 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 None: env = os.environ - else: - env = passed_env # subprocess.Popen keyword arguments self.kwargs = { - "env": copy.deepcopy(env) + "env": env.copy() } if platform.system().lower() == "windows": From c1d0870a7e471bccabc5342f8edd5268db192d91 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 22 Dec 2020 15:42:35 +0100 Subject: [PATCH 2/3] removed unused import --- pype/lib/applications.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pype/lib/applications.py b/pype/lib/applications.py index ce49eed961..94aed984fb 100644 --- a/pype/lib/applications.py +++ b/pype/lib/applications.py @@ -1,5 +1,4 @@ import os -import copy import platform import inspect import subprocess From 0b31fe75262153a67f33b0af4506a15d4b6ccb03 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 22 Dec 2020 15:48:43 +0100 Subject: [PATCH 3/3] make sure it's totally independent --- pype/lib/applications.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pype/lib/applications.py b/pype/lib/applications.py index 94aed984fb..253ffa0ad2 100644 --- a/pype/lib/applications.py +++ b/pype/lib/applications.py @@ -531,12 +531,22 @@ class ApplicationLaunchContext: # Handle launch environemtns 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 # subprocess.Popen keyword arguments self.kwargs = { - "env": env.copy() + "env": { + key: str(value) + for key, value in env.items() + } } if platform.system().lower() == "windows":