Skip to content

Commit

Permalink
Fix DeprecationWarning related to collections.Mapping
Browse files Browse the repository at this point in the history
This warning got reported in #367
  • Loading branch information
svisser committed Dec 14, 2018
1 parent e72fd3b commit e6ef8af
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion voluptuous/schema_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def iteritems(d):
def iteritems(d):
return d.iteritems()

if sys.version_info >= (3, 3):
_Mapping = collections.abc.Mapping
else:
_Mapping = collections.Mapping

"""Schema validation for Python data structures.
Given eg. a nested data structure like this:
Expand Down Expand Up @@ -280,7 +285,7 @@ def _compile(self, schema):
return schema.__voluptuous_compile__(self)
if isinstance(schema, Object):
return self._compile_object(schema)
if isinstance(schema, collections.Mapping):
if isinstance(schema, _Mapping):
return self._compile_dict(schema)
elif isinstance(schema, list):
return self._compile_list(schema)
Expand Down

0 comments on commit e6ef8af

Please sign in to comment.