summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-21 18:17:54 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-21 18:17:54 (GMT)
commit49d4022d7d56a027a8be0fc96f58d183bfbc2291 (patch)
tree54e47fc16eb2990f9c23b06e16e4473d09091beb
parent484dee38e665e20f961b18f27a82b3224341c1be (diff)
downloadcpython-49d4022d7d56a027a8be0fc96f58d183bfbc2291.zip
cpython-49d4022d7d56a027a8be0fc96f58d183bfbc2291.tar.gz
cpython-49d4022d7d56a027a8be0fc96f58d183bfbc2291.tar.bz2
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 71020fd..400e2d2 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -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
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
index d6a45d3..0be85da 100644
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -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__ = [
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py
index 7e2c68c..dc8916c 100644
--- a/Lib/json/decoder.py
+++ b/Lib/json/decoder.py
@@ -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
diff --git a/Lib/json/tool.py b/Lib/json/tool.py
index fe47c52..fc5d749 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 2c88b61..0b619fb 100644
--- 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