summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-11-09 22:32:05 (GMT)
committerGuido van Rossum <guido@python.org>1996-11-09 22:32:05 (GMT)
commit08ef9d98b2530d0a8e835ef4fb0a2a5f8bf64ced (patch)
treedc9b3baa4e73a2b0c98dd50be06731ad07cae7cb /Objects/abstract.c
parent115c1144ea5298b0c2e839412b5b98b11d840be9 (diff)
downloadcpython-08ef9d98b2530d0a8e835ef4fb0a2a5f8bf64ced.zip
cpython-08ef9d98b2530d0a8e835ef4fb0a2a5f8bf64ced.tar.gz
cpython-08ef9d98b2530d0a8e835ef4fb0a2a5f8bf64ced.tar.bz2
Only call sq_length in Sequence_GetItem for negative index.
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index bb197a5..8d07cfa 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -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);
}