# HG changeset patch # User Bob Ippolito <bob@redivi.com> # Date 1361468332 28800 # Thu Feb 21 09:38:52 2013 -0800 # Node ID 08df7633a87bc3079ba438dfaf5e6eeae2a56048 # Parent 42e9f52a7e6345a19574ac2778273eeedeacd8eb fix off-by-one error in the colno of JSONDecodeError when lineno == 0 (#57) diff --git a/CHANGES.txt b/CHANGES.txt --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,9 @@ +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 * Fix a Python 2.x compiler warning for narrow unicode builds diff --git a/conf.py b/conf.py --- a/conf.py +++ b/conf.py @@ -44,7 +44,7 @@ # The short X.Y version. version = '3.0' # 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 # non-false value, then it is used: diff --git a/index.rst b/index.rst --- a/index.rst +++ b/index.rst @@ -117,7 +117,7 @@ "json": "obj" } $ 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 diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ DistutilsPlatformError IS_PYPY = hasattr(sys, 'pypy_translation_info') -VERSION = '3.0.8' +VERSION = '3.0.9' DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python" with open('README.rst', 'r') as f: diff --git a/simplejson/__init__.py b/simplejson/__init__.py --- a/simplejson/__init__.py +++ b/simplejson/__init__.py @@ -96,10 +96,10 @@ "json": "obj" } $ 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 -__version__ = '3.0.8' +__version__ = '3.0.9' __all__ = [ 'dump', 'dumps', 'load', 'loads', 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder', diff --git a/simplejson/decoder.py b/simplejson/decoder.py --- a/simplejson/decoder.py +++ b/simplejson/decoder.py @@ -59,7 +59,7 @@ 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/simplejson/tests/test_errors.py b/simplejson/tests/test_errors.py --- a/simplejson/tests/test_errors.py +++ b/simplejson/tests/test_errors.py @@ -32,4 +32,4 @@ else: self.fail('Expected JSONDecodeError') self.assertEqual(err.lineno, 1) - self.assertEqual(err.colno, 9) + self.assertEqual(err.colno, 10) diff --git a/simplejson/tests/test_fail.py b/simplejson/tests/test_fail.py --- a/simplejson/tests/test_fail.py +++ b/simplejson/tests/test_fail.py @@ -111,7 +111,7 @@ e = sys.exc_info()[1] self.assertEqual(e.pos, 1) self.assertEqual(e.lineno, 1) - self.assertEqual(e.colno, 1) + self.assertEqual(e.colno, 2) except Exception: e = sys.exc_info()[1] self.fail("Unexpected exception raised %r %s" % (e, e))