[pypy-commit] pypy list-strategies: stop must not be smaller than start in rpython
l.diekmann
noreply at buildbot.pypy.org
Fri Sep 23 13:14:40 CEST 2011
Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: list-strategies
Changeset: r47514:527e4a735f22
Date: 2011-07-08 14:29 +0200
http://bitbucket.org/pypy/pypy/changeset/527e4a735f22/
Log: stop must not be smaller than start in rpython
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -518,12 +518,13 @@
getitems = getitems_copy
def getslice(self, w_list, start, stop, step, length):
- if step == 1:
+ if step == 1 and 0 <= start <= stop:
l = self.cast_from_void_star(w_list.lstorage)
assert start >= 0
assert stop >= 0
sublist = l[start:stop]
storage = self.cast_to_void_star(sublist)
+ #XXX check of empty list?
return W_ListObject.from_storage_and_strategy(self.space, storage, self)
else:
subitems_w = [None] * length
diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -527,6 +527,7 @@
l = [1,2,3,4,5]
assert l[1:0:None] == []
+ assert l[1:0] == []
def test_delall(self):
l = l0 = [1,2,3]
More information about the pypy-commit
mailing list