Issue #17225: JSON decoder now counts columns in the first line starting
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 21 Feb 2013 18:17:54 +0000 (20:17 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 21 Feb 2013 18:17:54 +0000 (20:17 +0200)
with 1, as in other lines.

Doc/library/json.rst
Lib/json/__init__.py
Lib/json/decoder.py
Lib/json/tool.py
Misc/NEWS

index 71020fd3cba626812e06a76307ac2e22a8b609d4..400e2d289bc981dec5b8fc3c748273272eff8a27 100644 (file)
@@ -103,7 +103,7 @@ Using json.tool from the shell to validate and pretty-print::
         "json": "obj"
     }
     $ echo '{1.2:3.4}' | python -mjson.tool
-    Expecting property name enclosed in double quotes: line 1 column 1 (char 1)
+    Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
 
 .. highlight:: python
 
index d6a45d3b425605cffe4c5e6d4e2e49e22588708c..0be85da022b2e88ddc21eb7cec57b69775300a4c 100644 (file)
@@ -95,7 +95,7 @@ Using json.tool from the shell to validate and pretty-print::
         "json": "obj"
     }
     $ echo '{ 1.2:3.4}' | python -m json.tool
-    Expecting property name enclosed in double quotes: line 1 column 2 (char 2)
+    Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
 """
 __version__ = '2.0.9'
 __all__ = [
index 7e2c68c8c46be3756c5d4ba8eba8bca00563284e..dc8916c9264f8189167d0a8c9923f0c51ea50c43 100644 (file)
@@ -27,7 +27,7 @@ NaN, PosInf, NegInf = _floatconstants()
 def linecol(doc, pos):
     lineno = doc.count('\n', 0, pos) + 1
     if lineno == 1:
-        colno = pos
+        colno = pos + 1
     else:
         colno = pos - doc.rindex('\n', 0, pos)
     return lineno, colno
index fe47c52d41631df324250616153f38968d3004fe..fc5d74923df2abef7a6c94e2d34eba7c13fecded 100644 (file)
@@ -7,7 +7,7 @@ Usage::
         "json": "obj"
     }
     $ echo '{ 1.2:3.4}' | python -m json.tool
-    Expecting property name enclosed in double quotes: line 1 column 2 (char 2)
+    Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
 
 """
 import sys
index 2c88b61201df9a8113c506a0a19719543d01adaf..0b619fb40ee8b3ad9463f420011c4df2552c5d46 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -208,6 +208,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #17225: JSON decoder now counts columns in the first line starting
+  with 1, as in other lines.
+
 - Issue #7842: backported fix for py_compile.compile() syntax error handling.
 
 - Issue #13153: Tkinter functions now raise TclError instead of ValueError when