From: Ezio Melotti Date: Wed, 4 May 2011 11:40:53 +0000 (+0300) Subject: #11982: fix json.loads('""') to return u'' rather than ''. X-Git-Tag: v2.7.2rc1~76 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=df8a8f768d929b56e43c42299064e7bcaebee4c7;p=python #11982: fix json.loads('""') to return u'' rather than ''. --- diff --git a/Lib/json/tests/test_decode.py b/Lib/json/tests/test_decode.py index 95088b4544..082159560d 100644 --- a/Lib/json/tests/test_decode.py +++ b/Lib/json/tests/test_decode.py @@ -26,7 +26,8 @@ class TestDecode(TestCase): def test_empty_objects(self): self.assertEqual(json.loads('{}'), {}) self.assertEqual(json.loads('[]'), []) - self.assertEqual(json.loads('""'), "") + self.assertEqual(json.loads('""'), u"") + self.assertIsInstance(json.loads('""'), unicode) def test_object_pairs_hook(self): s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}' diff --git a/Misc/NEWS b/Misc/NEWS index b14a6cb627..743f10ac1b 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -77,6 +77,8 @@ Core and Builtins Library ------- +- Issue #11982: fix json.loads('""') to return u'' rather than ''. + - Issue #11277: mmap.mmap() calls fcntl(fd, F_FULLFSYNC) on Mac OS X to get around a mmap bug with sparse files. Patch written by Steffen Daode Nurpmeso. diff --git a/Modules/_json.c b/Modules/_json.c index 71d3e58297..8d63edb2bf 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -595,7 +595,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict, Py_s Py_DECREF(chunk); } - rval = join_list_string(chunks); + rval = join_list_unicode(chunks); if (rval == NULL) { goto bail; }