[pypy-commit] pypy default: reuse the new helper here too
cfbolz
noreply at buildbot.pypy.org
Fri Nov 4 10:50:21 CET 2011
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch:
Changeset: r48731:81222f34969f
Date: 2011-11-03 21:03 +0100
http://bitbucket.org/pypy/pypy/changeset/81222f34969f/
Log: reuse the new helper here too
diff --git a/pypy/objspace/std/slicetype.py b/pypy/objspace/std/slicetype.py
--- a/pypy/objspace/std/slicetype.py
+++ b/pypy/objspace/std/slicetype.py
@@ -42,7 +42,7 @@
return index
@specialize.arg(4)
-def unwrap_start_stop(space, size, w_start, w_end, upper_bound):
+def unwrap_start_stop(space, size, w_start, w_end, upper_bound=False):
if space.is_w(w_start, space.w_None):
start = 0
elif upper_bound:
diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py
--- a/pypy/objspace/std/tupleobject.py
+++ b/pypy/objspace/std/tupleobject.py
@@ -167,17 +167,8 @@
return space.wrap(count)
def tuple_index__Tuple_ANY_ANY_ANY(space, w_tuple, w_obj, w_start, w_stop):
- start = slicetype.eval_slice_index(space, w_start)
- stop = slicetype.eval_slice_index(space, w_stop)
length = len(w_tuple.wrappeditems)
- if start < 0:
- start += length
- if start < 0:
- start = 0
- if stop < 0:
- stop += length
- if stop < 0:
- stop = 0
+ start, stop = slicetype.unwrap_start_stop(space, length, w_start, w_stop)
for i in range(start, min(stop, length)):
w_item = w_tuple.wrappeditems[i]
if space.eq_w(w_item, w_obj):
More information about the pypy-commit
mailing list