Commit 7f21f270 by Toshio Kuratomi

Be more lenient in instance check: MutableMapping is more general than dict

parent 3a87b272
...@@ -22,6 +22,7 @@ __metaclass__ = type ...@@ -22,6 +22,7 @@ __metaclass__ = type
import os import os
from collections import defaultdict from collections import defaultdict
from collections import MutableMapping
try: try:
from hashlib import sha1 from hashlib import sha1
...@@ -73,7 +74,7 @@ class VariableManager: ...@@ -73,7 +74,7 @@ class VariableManager:
def set_extra_vars(self, value): def set_extra_vars(self, value):
''' ensures a clean copy of the extra_vars are used to set the value ''' ''' ensures a clean copy of the extra_vars are used to set the value '''
assert isinstance(value, dict) assert isinstance(value, MutableMapping)
self._extra_vars = value.copy() self._extra_vars = value.copy()
def set_inventory(self, inventory): def set_inventory(self, inventory):
...@@ -83,7 +84,7 @@ class VariableManager: ...@@ -83,7 +84,7 @@ class VariableManager:
''' '''
Validates that both arguments are dictionaries, or an error is raised. Validates that both arguments are dictionaries, or an error is raised.
''' '''
if not (isinstance(a, dict) and isinstance(b, dict)): if not (isinstance(a, MutableMapping) and isinstance(b, MutableMapping)):
raise AnsibleError("failed to combine variables, expected dicts but got a '%s' and a '%s'" % (type(a).__name__, type(b).__name__)) raise AnsibleError("failed to combine variables, expected dicts but got a '%s' and a '%s'" % (type(a).__name__, type(b).__name__))
def _combine_vars(self, a, b): def _combine_vars(self, a, b):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment