summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt7
-rw-r--r--conf.py2
-rw-r--r--setup.py2
-rw-r--r--simplejson/__init__.py2
-rw-r--r--simplejson/encoder.py5
-rw-r--r--simplejson/tests/test_unicode.py13
6 files changed, 26 insertions, 5 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 375b28a..4e5aea4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,10 @@
+Version 3.0.6 released 2013-01-11
+
+* Fix for major Python 2.x ensure_ascii=False encoding regression
+ introduced in simplejson 3.0.0. If you use this setting, please
+ upgrade immediately.
+ https://github.com/simplejson/simplejson/issues/50
+
Version 3.0.5 released 2013-01-03
* NOTE: this release only changes the tests, it is
diff --git a/conf.py b/conf.py
index b5b7448..477121b 100644
--- a/conf.py
+++ b/conf.py
@@ -44,7 +44,7 @@ copyright = '2012, Bob Ippolito'
# The short X.Y version.
version = '3.0'
# The full version, including alpha/beta/rc tags.
-release = '3.0.5'
+release = '3.0.6'
# 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 607e7bc..7578766 100644
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,7 @@ from distutils.errors import CCompilerError, DistutilsExecError, \
DistutilsPlatformError
IS_PYPY = hasattr(sys, 'pypy_translation_info')
-VERSION = '3.0.5'
+VERSION = '3.0.6'
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 955d786..615e3e2 100644
--- a/simplejson/__init__.py
+++ b/simplejson/__init__.py
@@ -99,7 +99,7 @@ Using simplejson.tool from the shell to validate and pretty-print::
Expecting property name: line 1 column 2 (char 2)
"""
from __future__ import absolute_import
-__version__ = '3.0.5'
+__version__ = '3.0.6'
__all__ = [
'dump', 'dumps', 'load', 'loads',
'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
diff --git a/simplejson/encoder.py b/simplejson/encoder.py
index 432838b..db5c946 100644
--- a/simplejson/encoder.py
+++ b/simplejson/encoder.py
@@ -15,7 +15,10 @@ c_encode_basestring_ascii, c_make_encoder = _import_speedups()
from simplejson.decoder import PosInf
-ESCAPE = re.compile(u(r'[\x00-\x1f\\"\b\f\n\r\t\u2028\u2029]'))
+#ESCAPE = re.compile(ur'[\x00-\x1f\\"\b\f\n\r\t\u2028\u2029]')
+# This is required because u() will mangle the string and ur'' isn't valid
+# python3 syntax
+ESCAPE = re.compile(u'[\\x00-\\x1f\\\\"\\b\\f\\n\\r\\t\u2028\u2029]')
ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])')
HAS_UTF8 = re.compile(r'[\x80-\xff]')
ESCAPE_DCT = {
diff --git a/simplejson/tests/test_unicode.py b/simplejson/tests/test_unicode.py
index bade96c..f240176 100644
--- a/simplejson/tests/test_unicode.py
+++ b/simplejson/tests/test_unicode.py
@@ -142,4 +142,15 @@ class TestUnicode(TestCase):
self.assertRaises(json.JSONDecodeError, json.loads, '"\\ud800\\ux000"')
# invalid value for low surrogate
self.assertRaises(json.JSONDecodeError, json.loads, '"\\ud800\\u0000"')
- self.assertRaises(json.JSONDecodeError, json.loads, '"\\ud800\\ufc00"') \ No newline at end of file
+ self.assertRaises(json.JSONDecodeError, json.loads, '"\\ud800\\ufc00"')
+
+ def test_ensure_ascii_still_works(self):
+ # in the ascii range, ensure that everything is the same
+ for c in map(unichr, range(0, 127)):
+ self.assertEqual(
+ json.dumps(c, ensure_ascii=False),
+ json.dumps(c))
+ snowman = u'\N{SNOWMAN}'
+ self.assertEqual(
+ json.dumps(c, ensure_ascii=False),
+ '"' + c + '"')