From: Antoine Pitrou Date: Thu, 28 Jun 2012 23:59:54 +0000 (+0200) Subject: Issue #5067: improve some json error messages. X-Git-Tag: v3.3.0b2~370 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=802d669044b14ae535e0136c6a9949a1725b7e14;p=python Issue #5067: improve some json error messages. Patch by Serhiy Storchaka. --- 802d669044b14ae535e0136c6a9949a1725b7e14 diff --cc Modules/_json.c index 40c2ced502,2a71b9fda9..fb8bd594e9 --- a/Modules/_json.c +++ b/Modules/_json.c @@@ -645,8 -633,8 +645,8 @@@ _parse_object_unicode(PyScannerObject * PyObject *memokey; /* read key */ - if (str[idx] != '"') { + if (PyUnicode_READ(kind, str, idx) != '"') { - raise_errmsg("Expecting property name", pystr, idx); + raise_errmsg("Expecting property name enclosed in double quotes", pystr, idx); goto bail; } key = scanstring_unicode(pystr, idx + 1, strict, &next_idx); @@@ -665,9 -653,9 +665,9 @@@ idx = next_idx; /* skip whitespace between key and : delimiter, read :, skip whitespace */ - while (idx <= end_idx && IS_WHITESPACE(str[idx])) idx++; - if (idx > end_idx || str[idx] != ':') { + while (idx <= end_idx && IS_WHITESPACE(PyUnicode_READ(kind, str, idx))) idx++; + if (idx > end_idx || PyUnicode_READ(kind, str, idx) != ':') { - raise_errmsg("Expecting : delimiter", pystr, idx); + raise_errmsg("Expecting ':' delimiter", pystr, idx); goto bail; } idx++; @@@ -703,11 -691,11 +703,11 @@@ /* bail if the object is closed or we didn't get the , delimiter */ if (idx > end_idx) break; - if (str[idx] == '}') { + if (PyUnicode_READ(kind, str, idx) == '}') { break; } - else if (str[idx] != ',') { + else if (PyUnicode_READ(kind, str, idx) != ',') { - raise_errmsg("Expecting , delimiter", pystr, idx); + raise_errmsg("Expecting ',' delimiter", pystr, idx); goto bail; } idx++; @@@ -793,11 -773,11 +793,11 @@@ _parse_array_unicode(PyScannerObject *s /* bail if the array is closed or we didn't get the , delimiter */ if (idx > end_idx) break; - if (str[idx] == ']') { + if (PyUnicode_READ(kind, str, idx) == ']') { break; } - else if (str[idx] != ',') { + else if (PyUnicode_READ(kind, str, idx) != ',') { - raise_errmsg("Expecting , delimiter", pystr, idx); + raise_errmsg("Expecting ',' delimiter", pystr, idx); goto bail; } idx++;