diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-28 23:58:26 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-06-28 23:58:26 (GMT) |
commit | d9a5137742f066492c831c9b6f3eeb59c2e479b7 (patch) | |
tree | 8e3c65c89669e8a7ed91cd87e54afe3a4bf0411e /Lib/json/decoder.py | |
parent | d958cc960f8262c5ec8ec7993d966aa19e4dbe3e (diff) | |
download | cpython-d9a5137742f066492c831c9b6f3eeb59c2e479b7.zip cpython-d9a5137742f066492c831c9b6f3eeb59c2e479b7.tar.gz cpython-d9a5137742f066492c831c9b6f3eeb59c2e479b7.tar.bz2 |
Issue #5067: improve some json error messages.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/json/decoder.py')
-rw-r--r-- | Lib/json/decoder.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py index 1f2da72..7e2c68c 100644 --- a/Lib/json/decoder.py +++ b/Lib/json/decoder.py @@ -169,7 +169,8 @@ def JSONObject(s_and_end, encoding, strict, scan_once, object_hook, pairs = object_hook(pairs) return pairs, end + 1 elif nextchar != '"': - raise ValueError(errmsg("Expecting property name", s, end)) + raise ValueError(errmsg( + "Expecting property name enclosed in double quotes", s, end)) end += 1 while True: key, end = scanstring(s, end, encoding, strict) @@ -179,8 +180,7 @@ def JSONObject(s_and_end, encoding, strict, scan_once, object_hook, if s[end:end + 1] != ':': end = _w(s, end).end() if s[end:end + 1] != ':': - raise ValueError(errmsg("Expecting : delimiter", s, end)) - + raise ValueError(errmsg("Expecting ':' delimiter", s, end)) end += 1 try: @@ -209,7 +209,7 @@ def JSONObject(s_and_end, encoding, strict, scan_once, object_hook, if nextchar == '}': break elif nextchar != ',': - raise ValueError(errmsg("Expecting , delimiter", s, end - 1)) + raise ValueError(errmsg("Expecting ',' delimiter", s, end - 1)) try: nextchar = s[end] @@ -224,8 +224,8 @@ def JSONObject(s_and_end, encoding, strict, scan_once, object_hook, end += 1 if nextchar != '"': - raise ValueError(errmsg("Expecting property name", s, end - 1)) - + raise ValueError(errmsg( + "Expecting property name enclosed in double quotes", s, end - 1)) if object_pairs_hook is not None: result = object_pairs_hook(pairs) return result, end @@ -259,8 +259,7 @@ def JSONArray(s_and_end, scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR): if nextchar == ']': break elif nextchar != ',': - raise ValueError(errmsg("Expecting , delimiter", s, end)) - + raise ValueError(errmsg("Expecting ',' delimiter", s, end)) try: if s[end] in _ws: end += 1 |