diff options
-rw-r--r-- | Lib/json/scanner.py | 2 | ||||
-rw-r--r-- | Lib/test/test_json/test_decode.py | 4 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2018-05-22-13-05-12.bpo-30877.JZEGjI.rst | 3 |
3 files changed, 7 insertions, 2 deletions
diff --git a/Lib/json/scanner.py b/Lib/json/scanner.py index c451eba..7a61cfc 100644 --- a/Lib/json/scanner.py +++ b/Lib/json/scanner.py @@ -68,6 +68,6 @@ def py_make_scanner(context): finally: memo.clear() - return _scan_once + return scan_once make_scanner = c_make_scanner or py_make_scanner diff --git a/Lib/test/test_json/test_decode.py b/Lib/test/test_json/test_decode.py index d84ef7d..fdb9e62 100644 --- a/Lib/test/test_json/test_decode.py +++ b/Lib/test/test_json/test_decode.py @@ -58,7 +58,9 @@ class TestDecode: def test_keys_reuse(self): s = '[{"a_key": 1, "b_\xe9": 2}, {"a_key": 3, "b_\xe9": 4}]' self.check_keys_reuse(s, self.loads) - self.check_keys_reuse(s, self.json.decoder.JSONDecoder().decode) + decoder = self.json.decoder.JSONDecoder() + self.check_keys_reuse(s, decoder.decode) + self.assertFalse(decoder.memo) def test_extra_data(self): s = '[1, 2, 3]5' diff --git a/Misc/NEWS.d/next/Library/2018-05-22-13-05-12.bpo-30877.JZEGjI.rst b/Misc/NEWS.d/next/Library/2018-05-22-13-05-12.bpo-30877.JZEGjI.rst new file mode 100644 index 0000000..4be0fae --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-05-22-13-05-12.bpo-30877.JZEGjI.rst @@ -0,0 +1,3 @@ +Fixed a bug in the Python implementation of the JSON decoder that prevented +the cache of parsed strings from clearing after finishing the decoding. +Based on patch by c-fos. |