merge 3.2

This commit is contained in:
Benjamin Peterson 2014-04-13 22:28:16 -04:00
commit 156285c35f
4 changed files with 12 additions and 1 deletions

View file

@ -975,7 +975,10 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
kind = PyUnicode_KIND(pystr);
length = PyUnicode_GET_LENGTH(pystr);
if (idx >= length) {
if (idx < 0)
/* Compatibility with Python version. */
idx += length;
if (idx < 0 || idx >= length) {
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}