[pypy-commit] pypy list-strategies: RPython does not throw IndexError when there is not try/catch around

l.diekmann noreply at buildbot.pypy.org
Fri Sep 23 13:13:18 CEST 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: list-strategies
Changeset: r47503:eca3aafc0a2e
Date: 2011-04-25 16:34 +0200
http://bitbucket.org/pypy/pypy/changeset/eca3aafc0a2e/

Log:	RPython does not throw IndexError when there is not try/catch around

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
@@ -568,7 +568,10 @@
         l = self.cast_from_void_star(w_list.lstorage)
 
         if self.is_correct_type(w_item):
-            l[index] = self.unwrap(w_item)
+            try:
+                l[index] = self.unwrap(w_item)
+            except IndexError:
+                raise
             return
 
         w_list.switch_to_object_strategy()
@@ -644,7 +647,10 @@
 
     def deleteitem(self, w_list, index):
         l = self.cast_from_void_star(w_list.lstorage)
-        del l[index]
+        try:
+            del l[index]
+        except IndexError:
+            raise
         w_list.check_empty_strategy()
 
     def deleteslice(self, w_list, start, step, slicelength):
@@ -683,7 +689,14 @@
 
     def pop(self, w_list, index):
         l = self.cast_from_void_star(w_list.lstorage)
-        w_item = self.wrap(l.pop(index))
+        # not sure if RPython raises IndexError on pop
+        # so check again here
+        try:
+            item = l.pop(index)
+        except IndexError:
+            raise
+
+        w_item = self.wrap(item)
 
         w_list.check_empty_strategy()
         return w_item


More information about the pypy-commit mailing list