diff options
Diffstat (limited to 'Lib/json/decoder.py')
| -rw-r--r-- | Lib/json/decoder.py | 8 | 
1 files changed, 7 insertions, 1 deletions
| diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py index 12fa815..a19cf0f 100644 --- a/Lib/json/decoder.py +++ b/Lib/json/decoder.py @@ -147,10 +147,14 @@ WHITESPACE_STR = ' \t\n\r'  def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook, -        _w=WHITESPACE.match, _ws=WHITESPACE_STR): +               memo=None, _w=WHITESPACE.match, _ws=WHITESPACE_STR):      s, end = s_and_end      pairs = []      pairs_append = pairs.append +    # Backwards compatibility +    if memo is None: +        memo = {} +    memo_get = memo.setdefault      # Use a slice to prevent IndexError from being raised, the following      # check will raise a more specific ValueError if the string is empty      nextchar = s[end:end + 1] @@ -173,6 +177,7 @@ def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook,      end += 1      while True:          key, end = scanstring(s, end, strict) +        key = memo_get(key, key)          # To skip some function call overhead we optimize the fast paths where          # the JSON key separator is ": " or just ":".          if s[end:end + 1] != ':': @@ -334,6 +339,7 @@ class JSONDecoder(object):          self.parse_object = JSONObject          self.parse_array = JSONArray          self.parse_string = scanstring +        self.memo = {}          self.scan_once = make_scanner(self) | 
