diff options
author | Bob Ippolito <bob@redivi.com> | 2013-02-21 09:38:52 -0800 |
---|---|---|
committer | Bob Ippolito <bob@redivi.com> | 2013-02-21 09:38:52 -0800 |
commit | 44d7709a31f3a19f3d465411585ebb7be7fa2295 (patch) | |
tree | f022936eae4d165edd7e0766d62d20225bd3e521 | |
parent | 7b96b85710439cdc7dac16a4655bf407bfad77d7 (diff) | |
download | simplejson-44d7709a31f3a19f3d465411585ebb7be7fa2295.tar.gz |
fix off-by-one error in the colno of JSONDecodeError when lineno == 0 (#57)v3.0.9
-rw-r--r-- | CHANGES.txt | 6 | ||||
-rw-r--r-- | conf.py | 2 | ||||
-rw-r--r-- | index.rst | 2 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | simplejson/__init__.py | 4 | ||||
-rw-r--r-- | simplejson/decoder.py | 2 | ||||
-rw-r--r-- | simplejson/tests/test_errors.py | 2 | ||||
-rw-r--r-- | simplejson/tests/test_fail.py | 2 |
8 files changed, 14 insertions, 8 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index c915fe3..f26da7d 100644 --- 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 @@ -44,7 +44,7 @@ copyright = '2012, Bob Ippolito' # 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: @@ -117,7 +117,7 @@ Using :mod:`simplejson.tool` from the shell to validate and pretty-print:: "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 @@ -8,7 +8,7 @@ from distutils.errors import CCompilerError, DistutilsExecError, \ 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 index 2cba948..5574457 100644 --- a/simplejson/__init__.py +++ b/simplejson/__init__.py @@ -96,10 +96,10 @@ Using simplejson.tool from the shell to validate and pretty-print:: "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 index 546a168..d5a1968 100644 --- a/simplejson/decoder.py +++ b/simplejson/decoder.py @@ -59,7 +59,7 @@ class JSONDecodeError(ValueError): 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 index 4d3891a..6bc2fc8 100644 --- a/simplejson/tests/test_errors.py +++ b/simplejson/tests/test_errors.py @@ -32,4 +32,4 @@ class TestErrors(TestCase): 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 index dfc7207..f458a4b 100644 --- a/simplejson/tests/test_fail.py +++ b/simplejson/tests/test_fail.py @@ -111,7 +111,7 @@ class TestFail(TestCase): 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)) |