Skip to content

Commit 49d4022

Browse files
Issue python#17225: JSON decoder now counts columns in the first line starting
with 1, as in other lines.
1 parent 484dee3 commit 49d4022

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
@@ -103,7 +103,7 @@ Using json.tool from the shell to validate and pretty-print::
103103
"json": "obj"
104104
}
105105
$ echo '{1.2:3.4}' | python -mjson.tool
106-
Expecting property name enclosed in double quotes: line 1 column 1 (char 1)
106+
Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
107107

108108
.. highlight:: python
109109

‎Lib/json/__init__.py‎

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

‎Lib/json/decoder.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def _floatconstants():
2727
def linecol(doc, pos):
2828
lineno = doc.count('\n', 0, pos) + 1
2929
if lineno == 1:
30-
colno = pos
30+
colno = pos + 1
3131
else:
3232
colno = pos - doc.rindex('\n', 0, pos)
3333
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
@@ -208,6 +208,9 @@ Core and Builtins
208208
Library
209209
-------
210210

211+
- Issue #17225: JSON decoder now counts columns in the first line starting
212+
with 1, as in other lines.
213+
211214
- Issue #7842: backported fix for py_compile.compile() syntax error handling.
212215

213216
- Issue #13153: Tkinter functions now raise TclError instead of ValueError when

0 commit comments

Comments
 (0)