From 81804e672f22c236dda9412221674b762bb13ec4 Mon Sep 17 00:00:00 2001 From: Bob Ippolito Date: Mon, 1 Nov 2010 09:31:11 +0000 Subject: re http://code.google.com/p/simplejson/issues/detail?id=85 git-svn-id: http://simplejson.googlecode.com/svn/trunk@236 a4795897-2c25-0410-b006-0d3caba88fa1 --- CHANGES.txt | 2 ++ simplejson/decoder.py | 6 +++--- simplejson/tests/test_decode.py | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 671a862..4ff0722 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,7 @@ Version 2.1.2 released XXXX-XX-XX +* Correct wrong end when object_pairs_hook is used + http://code.google.com/p/simplejson/issues/detail?id=85 * Correct output for indent=0 http://bugs.python.org/issue10019 * Correctly raise TypeError when non-string keys are used with speedups diff --git a/simplejson/decoder.py b/simplejson/decoder.py index 9dd7fcb..e5496d6 100644 --- a/simplejson/decoder.py +++ b/simplejson/decoder.py @@ -31,7 +31,7 @@ NaN, PosInf, NegInf = _floatconstants() class JSONDecodeError(ValueError): """Subclass of ValueError with the following additional properties: - + msg: The unformatted error message doc: The JSON document being parsed pos: The start index of doc where parsing failed @@ -40,7 +40,7 @@ class JSONDecodeError(ValueError): colno: The column corresponding to pos endlineno: The line corresponding to end (may be None) endcolno: The column corresponding to end (may be None) - + """ def __init__(self, msg, doc, pos, end=None): ValueError.__init__(self, errmsg(msg, doc, pos, end=end)) @@ -197,7 +197,7 @@ def JSONObject((s, end), encoding, strict, scan_once, object_hook, if nextchar == '}': if object_pairs_hook is not None: result = object_pairs_hook(pairs) - return result, end + return result, end + 1 pairs = {} if object_hook is not None: pairs = object_hook(pairs) diff --git a/simplejson/tests/test_decode.py b/simplejson/tests/test_decode.py index a5a1c48..a140a13 100644 --- a/simplejson/tests/test_decode.py +++ b/simplejson/tests/test_decode.py @@ -71,3 +71,13 @@ class TestDecode(TestCase): self.assertEqual(json.loads(u'""'), u"") self.assertEqual(json.loads('[""]'), [""]) self.assertEqual(json.loads(u'[""]'), [u""]) + + def test_raw_decode(self): + cls = json.decoder.JSONDecoder + self.assertEqual( + ({'a': {}}, 9), + cls().raw_decode("{\"a\": {}}")) + # http://code.google.com/p/simplejson/issues/detail?id=85 + self.assertEqual( + ({'a': {}}, 9), + cls(object_pairs_hook=dict).raw_decode("{\"a\": {}}")) -- cgit v1.2.1