cpython: a220458179ed (original) (raw)

Mercurial > cpython

changeset 69319:a220458179ed 3.1

#9233: Fix json.loads({}) to return a dict (instead of a list), when _json is not available. [#9233]

Ezio Melotti
date Wed, 13 Apr 2011 07:10:13 +0300
parents ec6d881f5b02
children b279611146d7 bbed01a7d0d1
files Lib/json/decoder.py Lib/json/tests/test_decode.py
diffstat 2 files changed, 11 insertions(+), 0 deletions(-)[+] [-] Lib/json/decoder.py 6 Lib/json/tests/test_decode.py 5

line wrap: on

line diff

--- a/Lib/json/decoder.py +++ b/Lib/json/decoder.py @@ -161,6 +161,12 @@ def JSONObject(s_and_end, strict, scan_o nextchar = s[end:end + 1] # Trivial empty object if nextchar == '}':

--- a/Lib/json/tests/test_decode.py +++ b/Lib/json/tests/test_decode.py @@ -16,6 +16,11 @@ class TestDecode(TestCase): self.assertTrue(isinstance(rval, float)) self.assertEqual(rval, 1.0)

+ def test_object_pairs_hook(self): s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}' p = [("xkd", 1), ("kcw", 2), ("art", 3), ("hxm", 4),