diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..31d8275 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.linting.pylintEnabled": true +} diff --git a/json5/lib.py b/json5/lib.py index a7f6084..aa1fef1 100644 --- a/json5/lib.py +++ b/json5/lib.py @@ -19,7 +19,6 @@ from .parser import Parser - if sys.version_info[0] < 3: str_types = (str, unicode) str = unicode # pylint: disable=redefined-builtin, invalid-name @@ -290,7 +289,6 @@ def _dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, indent, item_sep, kv_sep = separators item_sep += indent_str - level += 1 if seen is not None: i = id(obj) @@ -306,17 +304,22 @@ def _dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, indent, check_circular, allow_nan, indent, separators, default, sort_keys, quote_keys, trailing_commas, - allow_duplicate_keys, seen, level, + allow_duplicate_keys, seen, level + 1, item_sep, kv_sep, indent_str, end_str) elif hasattr(obj, '__getitem__') and hasattr(obj, '__iter__'): s = _dump_array(obj, skipkeys, ensure_ascii, check_circular, allow_nan, indent, separators, default, sort_keys, quote_keys, trailing_commas, - allow_duplicate_keys, seen, level, + allow_duplicate_keys, seen, level + 1, item_sep, indent_str, end_str) else: - s = default(obj) + s = _dumps(default(obj), skipkeys, ensure_ascii, + check_circular, allow_nan, indent, + separators, default, sort_keys, + quote_keys, trailing_commas, + allow_duplicate_keys, seen, level, + is_key)[1] if seen is not None: seen.remove(i) diff --git a/tests/lib_test.py b/tests/lib_test.py index ba6b64e..f978650 100644 --- a/tests/lib_test.py +++ b/tests/lib_test.py @@ -18,7 +18,6 @@ import os import sys import unittest - from collections import OrderedDict from string import printable @@ -28,7 +27,6 @@ # Make the `hypothesis` library optional, so that the other tests will # still run if it isn't installed. import hypothesis.strategies as some - from hypothesis import given some_json = some.recursive( @@ -375,7 +373,7 @@ def _custom_serializer(obj): self.assertRaises(TypeError, json5.dumps, set()) self.assertEqual(json5.dumps(set(), default=_custom_serializer), - 'something') + '"something"') def test_ensure_ascii(self): self.check(u'\u00fc', '"\\u00fc"')