Author: Lukas Diekmann <[email protected]>
Branch: list-strategies
Changeset: r47520:8f6aec16e719
Date: 2011-07-29 12:44 +0200
http://bitbucket.org/pypy/pypy/changeset/8f6aec16e719/

Log:    moved negative-index check to list_pop__List_ANY

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
@@ -426,10 +426,6 @@
         w_list.deleteslice(start, step, slicelength)
 
     def pop(self, w_list, index):
-        #XXX move this to list_pop_List_ANY
-        if index < 0:
-            index += self.length(w_list)
-
         l = self.cast_from_void_star(w_list.lstorage)
         if index in [0, self.length(w_list)-1]:
             r = self.getitem(w_list, index)
@@ -1078,6 +1074,8 @@
         raise OperationError(space.w_IndexError,
                              space.wrap("pop from empty list"))
     idx = space.int_w(w_idx)
+    if idx < 0:
+        idx += w_list.length()
     try:
         return w_list.pop(idx)
     except IndexError:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to