Skip to content

Commit

Permalink
Merge pull request #77 from erikb85/master
Browse files Browse the repository at this point in the history
replace isinstance(...,dict) checks with Mapping
  • Loading branch information
EliAndrewC committed Nov 26, 2014
2 parents f99f93b + 88afa16 commit 0daebcb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions configobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import re
import sys
import collections

from codecs import BOM_UTF8, BOM_UTF16, BOM_UTF16_BE, BOM_UTF16_LE

Expand Down Expand Up @@ -595,7 +596,7 @@ def __setitem__(self, key, value, unrepr=False):
if key not in self:
self.sections.append(key)
dict.__setitem__(self, key, value)
elif isinstance(value, dict) and not unrepr:
elif isinstance(value, collections.Mapping) and not unrepr:
# First create the new depth level,
# then create the section
if key not in self:
Expand Down Expand Up @@ -802,8 +803,8 @@ def merge(self, indict):
ConfigObj({'section1': {'option1': 'False', 'subsection': {'more_options': 'False'}}})
"""
for key, val in list(indict.items()):
if (key in self and isinstance(self[key], dict) and
isinstance(val, dict)):
if (key in self and isinstance(self[key], collections.Mapping) and
isinstance(val, collections.Mapping)):
self[key].merge(val)
else:
self[key] = val
Expand Down Expand Up @@ -2440,7 +2441,7 @@ def flatten_errors(cfg, res, levels=None, results=None):
for (key, val) in list(res.items()):
if val == True:
continue
if isinstance(cfg.get(key), dict):
if isinstance(cfg.get(key), collections.Mapping):
# Go down one level
levels.append(key)
flatten_errors(cfg[key], val, levels, results)
Expand Down

0 comments on commit 0daebcb

Please sign in to comment.