Skip to content

Commit

Permalink
bpo-30877: Fix clearing a cache in the the JSON decoder. (GH-7048)
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored May 22, 2018
1 parent 55bfe69 commit ae00fb1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Lib/json/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ def scan_once(string, idx):
finally:
memo.clear()

return _scan_once
return scan_once

make_scanner = c_make_scanner or py_make_scanner
4 changes: 3 additions & 1 deletion Lib/test/test_json/test_decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def check_keys_reuse(self, source, loads):
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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit ae00fb1

Please sign in to comment.