Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c510a04

Browse files
Issue #17225: JSON decoder now counts columns in the first line starting
with 1, as in other lines.
1 parent a2964b3 commit c510a04

5 files changed

Lines changed: 7 additions & 4 deletions

File tree

Doc/library/json.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Using json.tool from the shell to validate and pretty-print::
102102
"json": "obj"
103103
}
104104
$ echo '{1.2:3.4}' | python -mjson.tool
105-
Expecting property name enclosed in double quotes: line 1 column 1 (char 1)
105+
Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
106106

107107
.. highlight:: python3
108108

Lib/json/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"json": "obj"
9898
}
9999
$ echo '{ 1.2:3.4}' | python -m json.tool
100-
Expecting property name enclosed in double quotes: line 1 column 2 (char 2)
100+
Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
101101
"""
102102
__version__ = '2.0.9'
103103
__all__ = [

Lib/json/decoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def linecol(doc, pos):
3232
newline = '\n'
3333
lineno = doc.count(newline, 0, pos) + 1
3434
if lineno == 1:
35-
colno = pos
35+
colno = pos + 1
3636
else:
3737
colno = pos - doc.rindex(newline, 0, pos)
3838
return lineno, colno

Lib/json/tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"json": "obj"
88
}
99
$ echo '{ 1.2:3.4}' | python -m json.tool
10-
Expecting property name enclosed in double quotes: line 1 column 2 (char 2)
10+
Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
1111
1212
"""
1313
import sys

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ Core and Builtins
227227
Library
228228
-------
229229

230+
- Issue #17225: JSON decoder now counts columns in the first line starting
231+
with 1, as in other lines.
232+
230233
- Issue #13700: Fix byte/string handling in imaplib authentication when an
231234
authobject is specified.
232235

0 commit comments

Comments
 (0)