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 | 2d24e94bbef97913b5fc434f991fa429f1533557 (patch) | |
tree | 0423c88ed968018d13bb60d7dc9687f99ab06811 /Lib/json/decoder.py | |
parent | 24319ac40737a3c305bbadca4f89c607a54ec967 (diff) | |
download | cpython-2d24e94bbef97913b5fc434f991fa429f1533557.zip cpython-2d24e94bbef97913b5fc434f991fa429f1533557.tar.gz cpython-2d24e94bbef97913b5fc434f991fa429f1533557.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 | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py index 3174e31..dc1155b 100644 --- a/Lib/json/decoder.py +++ b/Lib/json/decoder.py @@ -173,7 +173,8 @@ def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_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, strict) @@ -183,7 +184,7 @@ def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_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: @@ -211,12 +212,13 @@ def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook, if nextchar == '}': break elif nextchar != ',': - raise ValueError(errmsg("Expecting , delimiter", s, end - 1)) + raise ValueError(errmsg("Expecting ',' delimiter", s, end - 1)) end = _w(s, end).end() nextchar = s[end:end + 1] 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 @@ -250,7 +252,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 |