summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2014-09-29 14:18:04 -0700
committerBob Ippolito <bob@redivi.com>2014-09-29 14:18:04 -0700
commit54d5ff15d508c51366986cc4f77f2f287f036582 (patch)
tree733ef8a1775b5a5b93b6b2750a6baa5f9614f92c
parent2e83d7cc9388678ef750f7ccfa30947eed47e73d (diff)
parentccc8a2bc450f8b7f6db71a6daef4d4b069ba5851 (diff)
downloadsimplejson-54d5ff15d508c51366986cc4f77f2f287f036582.tar.gz
Merge pull request #107 from simplejson/sort_keys_dump-106v3.6.4
Fix dump's implementation of sort_keys
-rw-r--r--CHANGES.txt5
-rw-r--r--conf.py2
-rw-r--r--setup.py2
-rw-r--r--simplejson/__init__.py16
-rw-r--r--simplejson/tests/test_dump.py9
5 files changed, 26 insertions, 8 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 0bfde2e..bd6d978 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,8 @@
+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
* Documentation updates
diff --git a/conf.py b/conf.py
index 952b979..5d44941 100644
--- a/conf.py
+++ b/conf.py
@@ -44,7 +44,7 @@ copyright = '2014, Bob Ippolito'
# The short X.Y version.
version = '3.6'
# 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
# non-false value, then it is used:
diff --git a/setup.py b/setup.py
index 31237bf..d937ae2 100644
--- a/setup.py
+++ b/setup.py
@@ -11,7 +11,7 @@ from distutils.errors import CCompilerError, DistutilsExecError, \
DistutilsPlatformError
IS_PYPY = hasattr(sys, 'pypy_translation_info')
-VERSION = '3.6.3'
+VERSION = '3.6.4'
DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python"
with open('README.rst', 'r') as f:
diff --git a/simplejson/__init__.py b/simplejson/__init__.py
index a02c4de..cbb5b34 100644
--- a/simplejson/__init__.py
+++ b/simplejson/__init__.py
@@ -98,7 +98,7 @@ Using simplejson.tool from the shell to validate and pretty-print::
Expecting property name: line 1 column 3 (char 2)
"""
from __future__ import absolute_import
-__version__ = '3.6.3'
+__version__ = '3.6.4'
__all__ = [
'dump', 'dumps', 'load', 'loads',
'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
@@ -243,8 +243,11 @@ def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
cls is None and indent is None and separators is None and
encoding == 'utf-8' and default is None and use_decimal
and namedtuple_as_object and tuple_as_array
- and not bigint_as_string and int_as_string_bitcount is None
- and not item_sort_key and not for_json and not ignore_nan and not kw):
+ and not bigint_as_string and not sort_keys
+ 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)
else:
if cls is None:
@@ -359,9 +362,10 @@ def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
cls is None and indent is None and separators is None and
encoding == 'utf-8' and default is None and use_decimal
and namedtuple_as_object and tuple_as_array
- and not bigint_as_string and int_as_string_bitcount is None
- and not sort_keys and not item_sort_key and not for_json
- and not ignore_nan and not kw
+ and not bigint_as_string and not sort_keys
+ and not item_sort_key and not for_json
+ and not ignore_nan and int_as_string_bitcount is None
+ and not kw
):
return _default_encoder.encode(obj)
if cls is None:
diff --git a/simplejson/tests/test_dump.py b/simplejson/tests/test_dump.py
index 1d118d9..3661de0 100644
--- a/simplejson/tests/test_dump.py
+++ b/simplejson/tests/test_dump.py
@@ -119,3 +119,12 @@ class TestDump(TestCase):
# the C API uses an accumulator that collects after 100,000 appends
lst = [0] * 100000
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)