[Python-checkins] cpython (3.2): Issue #17225: JSON decoder now counts columns in the first line starting

serhiy.storchaka python-checkins at python.org
Thu Feb 21 19:31:13 CET 2013


http://hg.python.org/cpython/rev/36220cf535aa
changeset:   82301:36220cf535aa
branch:      3.2
parent:      82297:0f7383e6ced7
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Thu Feb 21 20:19:16 2013 +0200
summary:
  Issue #17225: JSON decoder now counts columns in the first line starting
with 1, as in other lines.

files:
  Doc/library/json.rst |  2 +-
  Lib/json/__init__.py |  2 +-
  Lib/json/decoder.py  |  2 +-
  Lib/json/tool.py     |  2 +-
  Misc/NEWS            |  3 +++
  5 files changed, 7 insertions(+), 4 deletions(-)


diff --git a/Doc/library/json.rst b/Doc/library/json.rst
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -102,7 +102,7 @@
         "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:: python3
 
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -97,7 +97,7 @@
         "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__ = [
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py
--- a/Lib/json/decoder.py
+++ b/Lib/json/decoder.py
@@ -32,7 +32,7 @@
         newline = '\n'
     lineno = doc.count(newline, 0, pos) + 1
     if lineno == 1:
-        colno = pos
+        colno = pos + 1
     else:
         colno = pos - doc.rindex(newline, 0, pos)
     return lineno, colno
diff --git a/Lib/json/tool.py b/Lib/json/tool.py
--- a/Lib/json/tool.py
+++ b/Lib/json/tool.py
@@ -7,7 +7,7 @@
         "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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -227,6 +227,9 @@
 Library
 -------
 
+- Issue #17225: JSON decoder now counts columns in the first line starting
+  with 1, as in other lines.
+
 - Issue #13700: Fix byte/string handling in imaplib authentication when an
   authobject is specified.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list