Skip to content

Commit 7f7cd4a

Browse files
committed
merge 3.3
2 parents e4e6463 + c64c3ad commit 7f7cd4a

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

Modules/_json.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -941,10 +941,11 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
941941
kind = PyUnicode_KIND(pystr);
942942
length = PyUnicode_GET_LENGTH(pystr);
943943

944-
if (idx < 0)
945-
/* Compatibility with Python version. */
946-
idx += length;
947-
if (idx < 0 || idx >= length) {
944+
if (idx < 0) {
945+
PyErr_SetString(PyExc_ValueError, "idx cannot be negative");
946+
return NULL;
947+
}
948+
if (idx >= length) {
948949
raise_stop_iteration(idx);
949950
return NULL;
950951
}

0 commit comments

Comments
 (0)