diff options
author | Lars Kellogg-Stedman <lars@redhat.com> | 2016-10-07 11:05:59 -0400 |
---|---|---|
committer | Thomas Herve <therve@redhat.com> | 2017-03-13 16:56:48 +0100 |
commit | c5889e9fdba7b9a05dca14b0dc0c89b0591fa89b (patch) | |
tree | 871e58647cf2ced65e1796c0b3c15ce77d320925 | |
parent | 3c3f8ee2c6c988c95c949cb20fa7969a7e4a9c1a (diff) | |
download | python-heatclient-c5889e9fdba7b9a05dca14b0dc0c89b0591fa89b.tar.gz |
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
(cherry picked from commit 0d218c92beb8f0fa11a18c2dc56bb92ed7feb785)
-rw-r--r-- | heatclient/common/template_utils.py | 6 |
1 files changed, 6 insertions, 0 deletions
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) |