mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Only call sq_length in Sequence_GetItem for negative index.
This commit is contained in:
parent
115c1144ea
commit
08ef9d98b2
1 changed files with 6 additions and 4 deletions
|
@ -666,12 +666,14 @@ PySequence_GetItem(s, i)
|
|||
|
||||
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__");
|
||||
|
||||
if(0 > (l=m->sq_length(s))) return NULL;
|
||||
|
||||
if(i < 0) i += l;
|
||||
if(i < 0)
|
||||
{
|
||||
if(0 > (l=m->sq_length(s))) return NULL;
|
||||
i += l;
|
||||
}
|
||||
|
||||
return m->sq_item(s,i);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue