From: Michael Tremer Date: Wed, 1 Dec 2021 21:42:00 +0000 (+0000) Subject: Tolerate setting an empty environment X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de18c5e19074013c221920110af40e780c91fd90;p=telemetry.git Tolerate setting an empty environment Signed-off-by: Michael Tremer --- diff --git a/src/collecty/plugins/base.py b/src/collecty/plugins/base.py index 5fedb85..561fa7b 100644 --- a/src/collecty/plugins/base.py +++ b/src/collecty/plugins/base.py @@ -50,10 +50,12 @@ class Environment(object): self.old_environment = {} for k in self.new_environment: + # Store the old value self.old_environment[k] = os.environ.get(k, None) - # Apply the new one - os.environ.update(self.new_environment) + # Apply the new one + if self.new_environment[k]: + os.environ.update(self.new_environment[k]) def __exit__(self, type, value, traceback): # Roll back to the previous environment