From 54dbfba8f8c83f226eff3ab53a1ec3e099fe1e56 Mon Sep 17 00:00:00 2001 From: Marius Gedminas Date: Tue, 1 Sep 2015 09:39:59 +0300 Subject: [PATCH] Make combine_vars() compatible with Python 3 Fixes TypeError: unsupported operand type(s) for +: 'dict_items' and 'dict_items' on Python 3. --- lib/ansible/utils/vars.py | 4 +++- lib/ansible/vars/__init__.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ansible/utils/vars.py b/lib/ansible/utils/vars.py index d53473412f..ba232c2b68 100644 --- a/lib/ansible/utils/vars.py +++ b/lib/ansible/utils/vars.py @@ -32,7 +32,9 @@ def combine_vars(a, b): if C.DEFAULT_HASH_BEHAVIOUR == "merge": return merge_hash(a, b) else: - return dict(a.items() + b.items()) + result = a.copy() + result.update(b) + return result def merge_hash(a, b): ''' recursively merges hash b into a diff --git a/lib/ansible/vars/__init__.py b/lib/ansible/vars/__init__.py index 4eeedb1b05..8ceed9d3a2 100644 --- a/lib/ansible/vars/__init__.py +++ b/lib/ansible/vars/__init__.py @@ -121,7 +121,9 @@ class VariableManager: if C.DEFAULT_HASH_BEHAVIOUR == "merge": return self._merge_dicts(a, b) else: - return dict(a.items() + b.items()) + result = a.copy() + result.update(b) + return result def _merge_dicts(self, a, b): '''