Re: [Python-Dev] [Python-checkins] cpython (3.1): disallow a negative idx parameter

2014年4月14日 09:16:42 -0700

On Mon, Apr 14, 2014 at 10:52 AM, benjamin.peterson
<[email protected]> wrote:
> http://hg.python.org/cpython/rev/4bd1fb0f4f44
> changeset: 90256:4bd1fb0f4f44
> branch: 3.1
> parent: 90235:a8facac493ef
> user: Benjamin Peterson <[email protected]>
> date: Mon Apr 14 11:45:21 2014 -0400
> summary:
> disallow a negative idx parameter
>
> files:
> Modules/_json.c | 9 +++++----
> 1 files changed, 5 insertions(+), 4 deletions(-)
>
>
> diff --git a/Modules/_json.c b/Modules/_json.c
> --- a/Modules/_json.c
> +++ b/Modules/_json.c
> @@ -902,10 +902,11 @@
> PyObject *res;
> Py_UNICODE *str = PyUnicode_AS_UNICODE(pystr);
> Py_ssize_t length = PyUnicode_GET_SIZE(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");
s/canont/cannot/
Also in the comparable 3.2 commit, but not the 3.3+ merge.
Regards,
-- 
Zach
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to