From: Benjamin Peterson Date: Mon, 14 Apr 2014 15:46:51 +0000 (-0400) Subject: merge 3.2 X-Git-Tag: v3.4.1rc1~94^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9beee049b0ff72d684e342a5b77bba4fba2df59b;p=python merge 3.2 --- 9beee049b0ff72d684e342a5b77bba4fba2df59b diff --cc Modules/_json.c index ec980c93fa,4d0f3c473a..4bc585dc2a --- a/Modules/_json.c +++ b/Modules/_json.c @@@ -964,21 -928,13 +964,22 @@@ scan_once_unicode(PyScannerObject *s, P Returns a new PyObject representation of the term. */ PyObject *res; - Py_UNICODE *str = PyUnicode_AS_UNICODE(pystr); - Py_ssize_t length = PyUnicode_GET_SIZE(pystr); + void *str; + int kind; + Py_ssize_t length; + + if (PyUnicode_READY(pystr) == -1) + return NULL; + + str = PyUnicode_DATA(pystr); + 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 canont be negative"); ++ PyErr_SetString(PyExc_ValueError, "idx cannot be negative"); + return NULL; + } + if (idx >= length) { PyErr_SetNone(PyExc_StopIteration); return NULL; }