Mercurial > cpython-lru_cache-weakref
diff Lib/json/decoder.py @ 77842:7762816e3fcd 2.7
Issue #5067: improve some json error messages.
Patch by Serhiy Storchaka.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Fri, 29 Jun 2012 01:58:26 +0200 |
| parents | 5b0fecd2eba0 |
| children | ce583eb0bec2 |
line wrap: on
line diff
--- a/Lib/json/decoder.py Fri Jun 29 01:42:46 2012 +0200 +++ b/Lib/json/decoder.py Fri Jun 29 01:58:26 2012 +0200 @@ -169,7 +169,8 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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
