From 56c7db5201f548aff7950e778ca0e106709623ae Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Fri, 29 May 2015 17:32:18 +0100 Subject: Do not call str() on None types in sanitize_env For a cluster morph, - morph: systems/devel-system-x86_64-generic.morph deploy: self: type: ssh-rsync location: root@127.0.0.1 ATTACK_KITTENS: The yaml parser will assign the value None to the element with key 'ATTACK_KITTENS', sanitize_environment blindly calls str() on each value in the dictionary, the result is that our extensions receive an 'ATTACK_KITTENS' environment variable with the string value 'None', this is not useful and confuses anyone trying to do basic validation in their extension. This patch makes it so that any None types are replaced with the empty string, which seems a more sensible value for this case. Change-Id: I734d33e9304f0b7d4d590e464e350d2e5b4720d3 --- morphlib/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/morphlib/util.py b/morphlib/util.py index 9668bac5..b533dd15 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -498,7 +498,7 @@ def get_host_architecture(): # pragma: no cover def sanitize_environment(env): for k in env: - env[k] = str(env[k]) + env[k] = '' if env[k] is None else str(env[k]) def iter_trickle(iterable, limit): '''Split an iterable up into `limit` length chunks.''' -- cgit v1.2.1