diff --git a/toml/encoder.py b/toml/encoder.py index bf17a72..e5f81aa 100644 --- a/toml/encoder.py +++ b/toml/encoder.py @@ -1,3 +1,4 @@ +import collections import datetime import re import sys @@ -161,7 +162,7 @@ def dump_inline_table(self, section): https://github.com/toml-lang/toml#user-content-inline-table """ retval = "" - if isinstance(section, dict): + if isinstance(section, collections.abc.Mapping): val_list = [] for k, v in section.items(): val = self.dump_inline_table(v) @@ -190,11 +191,11 @@ def dump_sections(self, o, sup): qsection = section if not re.match(r'^[A-Za-z0-9_-]+$', section): qsection = _dump_str(section) - if not isinstance(o[section], dict): + if not isinstance(o[section], collections.abc.Mapping): arrayoftables = False if isinstance(o[section], list): for a in o[section]: - if isinstance(a, dict): + if isinstance(a, collections.abc.Mapping): arrayoftables = True if arrayoftables: for a in o[section]: