summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2016-10-28 17:25:09 +0800
committerBob Ippolito <bob@redivi.com>2016-10-28 17:25:09 +0800
commitdd0f99d6431b5e75293369f5554a1396f8ae6251 (patch)
tree47c875fd61c3c9a1f1c9f56fb535ff68dae82ff5
parent392e2e7b51635b060dafdb4a08c130fa26421685 (diff)
downloadsimplejson-dd0f99d6431b5e75293369f5554a1396f8ae6251.tar.gz
Bump version, update changelog, fix issues identified in code review of #143
-rw-r--r--CHANGES.txt5
-rw-r--r--conf.py4
-rw-r--r--setup.py2
-rw-r--r--simplejson/__init__.py2
-rw-r--r--simplejson/encoder.py6
-rw-r--r--simplejson/tests/__init__.py1
-rw-r--r--simplejson/tests/test_raw_json.py17
7 files changed, 32 insertions, 5 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 06bb692..f6b8c25 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,8 @@
+Version 3.10.0 released XXXX-XX-XX
+
+* Add RawJSON class to allow a faster path for already encoded JSON.
+ https://github.com/simplejson/simplejson/pull/143
+
Version 3.9.0 released 2016-10-21
* Workaround for bad behavior in string subclasses
diff --git a/conf.py b/conf.py
index 766271c..c7ea050 100644
--- a/conf.py
+++ b/conf.py
@@ -42,9 +42,9 @@ copyright = '2016, Bob Ippolito'
# other places throughout the built documents.
#
# The short X.Y version.
-version = '3.9'
+version = '3.10'
# The full version, including alpha/beta/rc tags.
-release = '3.9.0'
+release = '3.10.0'
# 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 b24fe7d..ade96fa 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.9.0'
+VERSION = '3.10.0'
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 37a6012..d4876cd 100644
--- a/simplejson/__init__.py
+++ b/simplejson/__init__.py
@@ -97,7 +97,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.9.0'
+__version__ = '3.10.0'
__all__ = [
'dump', 'dumps', 'load', 'loads',
'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
diff --git a/simplejson/encoder.py b/simplejson/encoder.py
index 9c9b81e..226480f 100644
--- a/simplejson/encoder.py
+++ b/simplejson/encoder.py
@@ -40,9 +40,13 @@ for i in [0x2028, 0x2029]:
FLOAT_REPR = repr
class RawJSON(object):
+ """Wrap an encoded JSON document for direct embedding in the output
+
+ """
def __init__(self, encoded_json):
self.encoded_json = encoded_json
+
def encode_basestring(s, _PY3=PY3, _q=u('"')):
"""Return a JSON representation of a Python string
@@ -641,7 +645,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
(_PY3 and isinstance(o, binary_type))):
yield _encoder(o)
elif isinstance(o, RawJSON):
- buf + o.encoded_json
+ yield o.encoded_json
elif o is None:
yield 'null'
elif o is True:
diff --git a/simplejson/tests/__init__.py b/simplejson/tests/__init__.py
index 3a00b08..95e98e5 100644
--- a/simplejson/tests/__init__.py
+++ b/simplejson/tests/__init__.py
@@ -65,6 +65,7 @@ def all_tests_suite():
'simplejson.tests.test_tool',
'simplejson.tests.test_for_json',
'simplejson.tests.test_subclass',
+ 'simplejson.tests.test_raw_json',
]))
suite = get_suite()
import simplejson
diff --git a/simplejson/tests/test_raw_json.py b/simplejson/tests/test_raw_json.py
index 6fa6349..1dfcc2c 100644
--- a/simplejson/tests/test_raw_json.py
+++ b/simplejson/tests/test_raw_json.py
@@ -28,3 +28,20 @@ class TestRawJson(unittest.TestCase):
def test_raw_json_str(self):
self.assertEqual(json.dumps(dct2), json.dumps(dct4))
+ self.assertEqual(dct2, json.loads(json.dumps(dct4)))
+
+ def test_list(self):
+ self.assertEqual(
+ json.dumps([dct2]),
+ json.dumps([json.RawJSON(json.dumps(dct2))]))
+ self.assertEqual(
+ [dct2],
+ json.loads(json.dumps([json.RawJSON(json.dumps(dct2))])))
+
+ def test_direct(self):
+ self.assertEqual(
+ json.dumps(dct2),
+ json.dumps(json.RawJSON(json.dumps(dct2))))
+ self.assertEqual(
+ dct2,
+ json.loads(json.dumps(json.RawJSON(json.dumps(dct2)))))