Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Lib/json/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Loading