From 0d218c92beb8f0fa11a18c2dc56bb92ed7feb785 Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Fri, 7 Oct 2016 11:05:59 -0400 Subject: handle empty sections in environment files If an environment file has an *empty* section, as in: parameter_defaults: This would ultimately fail in deep_update (in heatclient/common/template_utils.py), which would get called with old == None. This patch handles this situation by explicitly setting old = {} if deep_update is called with old == None. Change-Id: Ia7bee87cdb99e29c63c9dc163f8490fef3f24f24 Closes-bug: 1631408 --- heatclient/common/template_utils.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'heatclient/common') diff --git a/heatclient/common/template_utils.py b/heatclient/common/template_utils.py index 2a6504c..cf28aef 100644 --- a/heatclient/common/template_utils.py +++ b/heatclient/common/template_utils.py @@ -188,6 +188,12 @@ def normalise_file_path_to_url(path): def deep_update(old, new): '''Merge nested dictionaries.''' + + # Prevents an error if in a previous iteration + # old[k] = None but v[k] = {...}, + if old is None: + old = {} + for k, v in new.items(): if isinstance(v, collections.Mapping): r = deep_update(old.get(k, {}), v) -- cgit v1.2.1