Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9beee04

Browse files
committed
merge 3.2
2 parents 156285c + 6ef2b36 commit 9beee04

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
@@ -975,10 +975,11 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
975975
kind = PyUnicode_KIND(pystr);
976976
length = PyUnicode_GET_LENGTH(pystr);
977977

978-
if (idx < 0)
979-
/* Compatibility with Python version. */
980-
idx += length;
981-
if (idx < 0 || idx >= length) {
978+
if (idx < 0) {
979+
PyErr_SetString(PyExc_ValueError, "idx cannot be negative");
980+
return NULL;
981+
}
982+
if (idx >= length) {
982983
PyErr_SetNone(PyExc_StopIteration);
983984
return NULL;
984985
}

0 commit comments

Comments
 (0)