Skip to content
Snippets Groups Projects
Commit 08df7633a87b authored by Bob Ippolito's avatar Bob Ippolito
Browse files

fix off-by-one error in the colno of JSONDecodeError when lineno == 0 (#57)

parent 42e9f52a7e63
Branches
No related tags found
No related merge requests found
Version 3.0.9 released 2013-02-21
* Fix an off-by-one error in the colno property of JSONDecodeError
(when lineno == 1)
http://bugs.python.org/issue17225
Version 3.0.8 released 2013-02-19 Version 3.0.8 released 2013-02-19
* Fix a Python 2.x compiler warning for narrow unicode builds * Fix a Python 2.x compiler warning for narrow unicode builds
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
# The short X.Y version. # The short X.Y version.
version = '3.0' version = '3.0'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '3.0.8' release = '3.0.9'
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
......
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
"json": "obj" "json": "obj"
} }
$ echo '{ 1.2:3.4}' | python -m simplejson.tool $ echo '{ 1.2:3.4}' | python -m simplejson.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)
.. highlight:: python .. highlight:: python
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
DistutilsPlatformError DistutilsPlatformError
IS_PYPY = hasattr(sys, 'pypy_translation_info') IS_PYPY = hasattr(sys, 'pypy_translation_info')
VERSION = '3.0.8' VERSION = '3.0.9'
DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python" DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python"
with open('README.rst', 'r') as f: with open('README.rst', 'r') as f:
......
...@@ -96,6 +96,6 @@ ...@@ -96,6 +96,6 @@
"json": "obj" "json": "obj"
} }
$ echo '{ 1.2:3.4}' | python -m simplejson.tool $ echo '{ 1.2:3.4}' | python -m simplejson.tool
Expecting property name: line 1 column 2 (char 2) Expecting property name: line 1 column 3 (char 2)
""" """
from __future__ import absolute_import from __future__ import absolute_import
...@@ -100,6 +100,6 @@ ...@@ -100,6 +100,6 @@
""" """
from __future__ import absolute_import from __future__ import absolute_import
__version__ = '3.0.8' __version__ = '3.0.9'
__all__ = [ __all__ = [
'dump', 'dumps', 'load', 'loads', 'dump', 'dumps', 'load', 'loads',
'JSONDecoder', 'JSONDecodeError', 'JSONEncoder', 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
def linecol(doc, pos): def linecol(doc, pos):
lineno = doc.count('\n', 0, pos) + 1 lineno = doc.count('\n', 0, pos) + 1
if lineno == 1: if lineno == 1:
colno = pos colno = pos + 1
else: else:
colno = pos - doc.rindex('\n', 0, pos) colno = pos - doc.rindex('\n', 0, pos)
return lineno, colno return lineno, colno
......
...@@ -32,4 +32,4 @@ ...@@ -32,4 +32,4 @@
else: else:
self.fail('Expected JSONDecodeError') self.fail('Expected JSONDecodeError')
self.assertEqual(err.lineno, 1) self.assertEqual(err.lineno, 1)
self.assertEqual(err.colno, 9) self.assertEqual(err.colno, 10)
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
e = sys.exc_info()[1] e = sys.exc_info()[1]
self.assertEqual(e.pos, 1) self.assertEqual(e.pos, 1)
self.assertEqual(e.lineno, 1) self.assertEqual(e.lineno, 1)
self.assertEqual(e.colno, 1) self.assertEqual(e.colno, 2)
except Exception: except Exception:
e = sys.exc_info()[1] e = sys.exc_info()[1]
self.fail("Unexpected exception raised %r %s" % (e, e)) self.fail("Unexpected exception raised %r %s" % (e, e))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment