cpython: 69f793cc34fc (original) (raw)
--- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -101,7 +101,7 @@ Using json.tool from the shell to valida "json": "obj" } $ echo '{1.2:3.4}' | python -mjson.tool
--- a/Lib/json/init.py +++ b/Lib/json/init.py @@ -96,7 +96,7 @@ Using json.tool from the shell to valida "json": "obj" } $ echo '{ 1.2:3.4}' | python -m json.tool
--- a/Lib/json/decoder.py +++ b/Lib/json/decoder.py @@ -24,7 +24,7 @@ def linecol(doc, pos): newline = '\n' lineno = doc.count(newline, 0, pos) + 1 if lineno == 1:
colno = pos[](#l3.7)
--- a/Lib/json/tool.py +++ b/Lib/json/tool.py @@ -7,7 +7,7 @@ Usage:: "json": "obj" } $ echo '{ 1.2:3.4}' | python -m json.tool
--- a/Lib/test/json_tests/test_fail.py +++ b/Lib/test/json_tests/test_fail.py @@ -125,8 +125,8 @@ class TestFail: ] for data, msg, idx in test_cases: self.assertRaisesRegex(ValueError,
r'^{0}: line 1 column {1} \(char {1}\)'.format([](#l5.7)
re.escape(msg), idx),[](#l5.8)
r'^{0}: line 1 column {1} \(char {2}\)'.format([](#l5.9)
re.escape(msg), idx + 1, idx),[](#l5.10) self.loads, data)[](#l5.11)
def test_unexpected_data(self): @@ -155,8 +155,8 @@ class TestFail: ] for data, msg, idx in test_cases: self.assertRaisesRegex(ValueError,
r'^{0}: line 1 column {1} \(char {1}\)'.format([](#l5.18)
re.escape(msg), idx),[](#l5.19)
r'^{0}: line 1 column {1} \(char {2}\)'.format([](#l5.20)
re.escape(msg), idx + 1, idx),[](#l5.21) self.loads, data)[](#l5.22)
def test_extra_data(self): @@ -173,10 +173,22 @@ class TestFail: for data, msg, idx in test_cases: self.assertRaisesRegex(ValueError, r'^{0}: line 1 column {1} - line 1 column {2}'
r' \(char {1} - {2}\)'.format([](#l5.29)
re.escape(msg), idx, len(data)),[](#l5.30)
r' \(char {3} - {4}\)'.format([](#l5.31)
re.escape(msg), idx + 1, len(data) + 1, idx, len(data)),[](#l5.32) self.loads, data)[](#l5.33)
- def test_linecol(self):
test_cases = [[](#l5.36)
('!', 1, 1, 0),[](#l5.37)
(' !', 1, 2, 1),[](#l5.38)
('\n!', 2, 1, 1),[](#l5.39)
('\n \n\n !', 4, 6, 10),[](#l5.40)
][](#l5.41)
for data, line, col, idx in test_cases:[](#l5.42)
self.assertRaisesRegex(ValueError,[](#l5.43)
r'^Expecting value: line {0} column {1}'[](#l5.44)
r' \(char {2}\)$'.format(line, col, idx),[](#l5.45)
self.loads, data)[](#l5.46)
class TestPyFail(TestFail, PyTest): pass class TestCFail(TestFail, CTest): pass
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -260,6 +260,9 @@ Core and Builtins Library ------- +- Issue #17225: JSON decoder now counts columns in the first line starting