diff --git a/CHANGES.txt b/CHANGES.txt index 4682e9d80cbb53ba595086eb57d23a06cad062e9_Q0hBTkdFUy50eHQ=..561bc4581343cdfbf86534e43a2bd3d6685bce81_Q0hBTkdFUy50eHQ= 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 4682e9d80cbb53ba595086eb57d23a06cad062e9_Y29uZi5weQ==..561bc4581343cdfbf86534e43a2bd3d6685bce81_Y29uZi5weQ== 100644 --- a/conf.py +++ b/conf.py @@ -44,7 +44,7 @@ # 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 4682e9d80cbb53ba595086eb57d23a06cad062e9_c2V0dXAucHk=..561bc4581343cdfbf86534e43a2bd3d6685bce81_c2V0dXAucHk= 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ 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 4682e9d80cbb53ba595086eb57d23a06cad062e9_c2ltcGxlanNvbi9fX2luaXRfXy5weQ==..561bc4581343cdfbf86534e43a2bd3d6685bce81_c2ltcGxlanNvbi9fX2luaXRfXy5weQ== 100644 --- a/simplejson/__init__.py +++ b/simplejson/__init__.py @@ -99,7 +99,7 @@ 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 4682e9d80cbb53ba595086eb57d23a06cad062e9_c2ltcGxlanNvbi9lbmNvZGVyLnB5..561bc4581343cdfbf86534e43a2bd3d6685bce81_c2ltcGxlanNvbi9lbmNvZGVyLnB5 100644 --- a/simplejson/encoder.py +++ b/simplejson/encoder.py @@ -15,7 +15,10 @@ 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 4682e9d80cbb53ba595086eb57d23a06cad062e9_c2ltcGxlanNvbi90ZXN0cy90ZXN0X3VuaWNvZGUucHk=..561bc4581343cdfbf86534e43a2bd3d6685bce81_c2ltcGxlanNvbi90ZXN0cy90ZXN0X3VuaWNvZGUucHk= 100644 --- a/simplejson/tests/test_unicode.py +++ b/simplejson/tests/test_unicode.py @@ -142,4 +142,15 @@ 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 + '"')