summaryrefslogtreecommitdiffstats
path: root/Modules/_json.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-04-14 15:48:21 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-04-14 15:48:21 (GMT)
commit70d92a96ab47e0b8b9cb78d437b3761296f815ed (patch)
treec7bc97e2e8adb45ab4ee090229fde0b215430824 /Modules/_json.c
parent1b16436c00aaabb3ec10c49ff4cc131c6aa9f4ca (diff)
parent9beee049b0ff72d684e342a5b77bba4fba2df59b (diff)
downloadcpython-70d92a96ab47e0b8b9cb78d437b3761296f815ed.zip
cpython-70d92a96ab47e0b8b9cb78d437b3761296f815ed.tar.gz
cpython-70d92a96ab47e0b8b9cb78d437b3761296f815ed.tar.bz2
merge 3.3
Diffstat (limited to 'Modules/_json.c')
-rw-r--r--Modules/_json.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index 7d627cb..20f4614 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -941,10 +941,11 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
kind = PyUnicode_KIND(pystr);
length = PyUnicode_GET_LENGTH(pystr);
- if (idx < 0)
- /* Compatibility with Python version. */
- idx += length;
- if (idx < 0 || idx >= length) {
+ if (idx < 0) {
+ PyErr_SetString(PyExc_ValueError, "idx cannot be negative");
+ return NULL;
+ }
+ if (idx >= length) {
raise_stop_iteration(idx);
return NULL;
}