Author: Lukas Diekmann <[email protected]>
Branch: list-strategies
Changeset: r47442:664e24c98b22
Date: 2011-02-25 16:13 +0100
http://bitbucket.org/pypy/pypy/changeset/664e24c98b22/

Log:    Removed remaining wrappeditems

diff --git a/pypy/objspace/std/frame.py b/pypy/objspace/std/frame.py
--- a/pypy/objspace/std/frame.py
+++ b/pypy/objspace/std/frame.py
@@ -58,7 +58,7 @@
     w_1 = f.popvalue()
     if type(w_1) is W_ListObject and type(w_2) is intobject.W_IntObject:
         try:
-            w_result = w_1.wrappeditems[w_2.intval]
+            w_result = w_1.getitem(w_2.intval)
         except IndexError:
             raise OperationError(f.space.w_IndexError,
                 f.space.wrap("list index out of range"))
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
@@ -57,7 +57,7 @@
         assert isinstance(wrappeditems, list)
         w_self.strategy = get_strategy_from_list_objects(wrappeditems)
         w_self.strategy.init_from_list_w(w_self, wrappeditems)
-        w_self.wrappeditems = wrappeditems
+        #w_self.wrappeditems = wrappeditems
 
     def __repr__(w_self):
         """ representation for debugging purposes """
@@ -68,11 +68,6 @@
         items = [space.unwrap(w_item) for w_item in w_list.getitems()]
         return list(items)
 
-    def _overwrite(w_self, items_w):
-        w_self.strategy = get_strategy_from_list_objects(items_w)
-        w_self.strategy.init_from_list_w(w_self, items_w)
-        w_self.wrappeditems = items_w
-
     def append(w_list, w_item):
         w_list.strategy.append(w_list, w_item)
 
@@ -250,7 +245,10 @@
         return len(self.cast_from_void_star(w_list.storage))
 
     def getitem(self, w_list, index):
-        return self.wrap(self.cast_from_void_star(w_list.storage)[index])
+        try:
+            return self.wrap(self.cast_from_void_star(w_list.storage)[index])
+        except IndexError: # make RPython raise the exception
+            raise
 
     def getitems(self, w_list):
         return self.cast_from_void_star(w_list.storage)
@@ -806,6 +804,7 @@
         return CustomCompareSort.lt(self, a.w_key, b.w_key)
 
 def list_sort__List_ANY_ANY_ANY(space, w_list, w_cmp, w_keyfunc, w_reverse):
+    #XXX so far sorting always wraps list
     has_cmp = not space.is_w(w_cmp, space.w_None)
     has_key = not space.is_w(w_keyfunc, space.w_None)
     has_reverse = space.is_true(w_reverse)
@@ -830,8 +829,7 @@
         # by comparison functions can't affect the slice of memory we're
         # sorting (allowing mutations during sorting is an IndexError or
         # core-dump factory, since wrappeditems may change).
-        w_list._overwrite([])
-        #w_list.wrappeditems = []
+        w_list.__init__([])
 
         # wrap each item in a KeyContainer if needed
         if has_key:
@@ -864,7 +862,7 @@
         mucked = w_list.length() > 0
 
         # put the items back into the list
-        w_list._overwrite(sorter.list)
+        w_list.__init__(sorter.list)
 
     if mucked:
         raise OperationError(space.w_ValueError,
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to