Skip to content
Snippets Groups Projects
Commit 4c8b383dce72 authored by Bob Ippolito's avatar Bob Ippolito
Browse files

Merge pull request #107 from simplejson/sort_keys_dump-106

Fix dump's implementation of sort_keys
No related branches found
No related tags found
No related merge requests found
Version 3.6.4 released 2014-09-29
* Important bug fix for dump when only sort_keys is set
https://github.com/simplejson/simplejson/issues/106
Version 3.6.3 released 2014-08-18 Version 3.6.3 released 2014-08-18
* Documentation updates * Documentation updates
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
# The short X.Y version. # The short X.Y version.
version = '3.6' version = '3.6'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '3.6.3' release = '3.6.4'
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
DistutilsPlatformError DistutilsPlatformError
IS_PYPY = hasattr(sys, 'pypy_translation_info') IS_PYPY = hasattr(sys, 'pypy_translation_info')
VERSION = '3.6.3' VERSION = '3.6.4'
DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python" DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python"
with open('README.rst', 'r') as f: with open('README.rst', 'r') as f:
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
Expecting property name: line 1 column 3 (char 2) Expecting property name: line 1 column 3 (char 2)
""" """
from __future__ import absolute_import from __future__ import absolute_import
__version__ = '3.6.3' __version__ = '3.6.4'
__all__ = [ __all__ = [
'dump', 'dumps', 'load', 'loads', 'dump', 'dumps', 'load', 'loads',
'JSONDecoder', 'JSONDecodeError', 'JSONEncoder', 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
...@@ -243,8 +243,11 @@ ...@@ -243,8 +243,11 @@
cls is None and indent is None and separators is None and cls is None and indent is None and separators is None and
encoding == 'utf-8' and default is None and use_decimal encoding == 'utf-8' and default is None and use_decimal
and namedtuple_as_object and tuple_as_array and namedtuple_as_object and tuple_as_array
and not bigint_as_string and int_as_string_bitcount is None and not bigint_as_string and not sort_keys
and not item_sort_key and not for_json and not ignore_nan and not kw): and not item_sort_key and not for_json
and not ignore_nan and int_as_string_bitcount is None
and not kw
):
iterable = _default_encoder.iterencode(obj) iterable = _default_encoder.iterencode(obj)
else: else:
if cls is None: if cls is None:
...@@ -359,9 +362,10 @@ ...@@ -359,9 +362,10 @@
cls is None and indent is None and separators is None and cls is None and indent is None and separators is None and
encoding == 'utf-8' and default is None and use_decimal encoding == 'utf-8' and default is None and use_decimal
and namedtuple_as_object and tuple_as_array and namedtuple_as_object and tuple_as_array
and not bigint_as_string and int_as_string_bitcount is None and not bigint_as_string and not sort_keys
and not sort_keys and not item_sort_key and not for_json and not item_sort_key and not for_json
and not ignore_nan and not kw and not ignore_nan and int_as_string_bitcount is None
and not kw
): ):
return _default_encoder.encode(obj) return _default_encoder.encode(obj)
if cls is None: if cls is None:
......
...@@ -119,3 +119,12 @@ ...@@ -119,3 +119,12 @@
# the C API uses an accumulator that collects after 100,000 appends # the C API uses an accumulator that collects after 100,000 appends
lst = [0] * 100000 lst = [0] * 100000
self.assertEqual(json.loads(json.dumps(lst)), lst) self.assertEqual(json.loads(json.dumps(lst)), lst)
def test_sort_keys(self):
# https://github.com/simplejson/simplejson/issues/106
for num_keys in range(2, 32):
p = dict((str(x), x) for x in range(num_keys))
sio = StringIO()
json.dump(p, sio, sort_keys=True)
self.assertEqual(sio.getvalue(), json.dumps(p, sort_keys=True))
self.assertEqual(json.loads(sio.getvalue()), p)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment