diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py index 364e44d40cc3073..51199f5cf0ff271 100644 --- a/Lib/json/decoder.py +++ b/Lib/json/decoder.py @@ -355,13 +355,13 @@ def decode(self, s, _w=WHITESPACE.match): containing a JSON document). """ - obj, end = self.raw_decode(s, idx=_w(s, 0).end()) + obj, end = self.raw_decode(s) end = _w(s, end).end() if end != len(s): raise JSONDecodeError("Extra data", s, end) return obj - def raw_decode(self, s, idx=0): + def raw_decode(self, s, idx=0, _w=WHITESPACE.match): """Decode a JSON document from ``s`` (a ``str`` beginning with a JSON document) and return a 2-tuple of the Python representation and the index in ``s`` where the document ended. @@ -371,7 +371,7 @@ def raw_decode(self, s, idx=0): """ try: - obj, end = self.scan_once(s, idx) + obj, end = self.scan_once(s, idx=_w(s, idx).end()) except StopIteration as err: raise JSONDecodeError("Expecting value", s, err.value) from None return obj, end