summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-21 20:19:16 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-21 20:19:16 +0200
commit7f29572e896d0a941fae889e68c525e5817c29aa (patch)
treed0322317203e1e599c69af8e4a8dad8533235d7c
parent8b9ea2547784c755bd183e6965d9ccf96990c73c (diff)
downloadcpython-7f29572e896d0a941fae889e68c525e5817c29aa.tar.gz
Issue #17225: JSON decoder now counts columns in the first line starting
with 1, as in other lines.
-rw-r--r--Doc/library/json.rst2
-rw-r--r--Lib/json/__init__.py2
-rw-r--r--Lib/json/decoder.py2
-rw-r--r--Lib/json/tool.py2
-rw-r--r--Misc/NEWS3
5 files changed, 7 insertions, 4 deletions
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index bdb6436e98..f98e0ef603 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -102,7 +102,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:: python3
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
index 44f49c4247..48a4f8f863 100644
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -97,7 +97,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__ = [
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py
index dc1155b1cc..0c59edd6ba 100644
--- a/Lib/json/decoder.py
+++ b/Lib/json/decoder.py
@@ -32,7 +32,7 @@ def linecol(doc, pos):
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
index 0f108c6dae..ecf9c47885 100644
--- 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
- 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
index 8cc7f5074f..401228efc5 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -227,6 +227,9 @@ Core and Builtins
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.