diff options
Diffstat (limited to 'Lib/json/scanner.py')
-rw-r--r-- | Lib/json/scanner.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/json/scanner.py b/Lib/json/scanner.py index b4f3561..23eef61 100644 --- a/Lib/json/scanner.py +++ b/Lib/json/scanner.py @@ -22,6 +22,8 @@ def py_make_scanner(context): parse_int = context.parse_int parse_constant = context.parse_constant object_hook = context.object_hook + object_pairs_hook = context.object_pairs_hook + memo = context.memo def _scan_once(string, idx): try: @@ -33,7 +35,7 @@ def py_make_scanner(context): return parse_string(string, idx + 1, strict) elif nextchar == '{': return parse_object((string, idx + 1), strict, - _scan_once, object_hook, object_pairs_hook) + _scan_once, object_hook, object_pairs_hook, memo) elif nextchar == '[': return parse_array((string, idx + 1), _scan_once) elif nextchar == 'n' and string[idx:idx + 4] == 'null': @@ -60,6 +62,12 @@ def py_make_scanner(context): else: raise StopIteration + def scan_once(string, idx): + try: + return _scan_once(string, idx) + finally: + memo.clear() + return _scan_once make_scanner = c_make_scanner or py_make_scanner |