Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.linting.pylintEnabled": true
}
13 changes: 8 additions & 5 deletions json5/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions tests/lib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import os
import sys
import unittest

from collections import OrderedDict
from string import printable

Expand All @@ -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(
Expand Down Expand Up @@ -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"')
Expand Down