Commit 08ef9d98 authored by Guido van Rossum's avatar Guido van Rossum

Only call sq_length in Sequence_GetItem for negative index.

parent 115c1144
...@@ -666,12 +666,14 @@ PySequence_GetItem(s, i) ...@@ -666,12 +666,14 @@ PySequence_GetItem(s, i)
if(! s) return Py_ReturnNullError(); if(! s) return Py_ReturnNullError();
if(! ((m=s->ob_type->tp_as_sequence) && m->sq_length && m->sq_item)) if(! ((m=s->ob_type->tp_as_sequence) && m->sq_item))
return Py_ReturnMethodError("__getitem__"); return Py_ReturnMethodError("__getitem__");
if(i < 0)
{
if(0 > (l=m->sq_length(s))) return NULL; if(0 > (l=m->sq_length(s))) return NULL;
i += l;
if(i < 0) i += l; }
return m->sq_item(s,i); return m->sq_item(s,i);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment