Author: Lukas Diekmann <[email protected]>
Branch: list-strategies
Changeset: r47487:d6d8f46ff357
Date: 2011-03-23 14:01 +0100
http://bitbucket.org/pypy/pypy/changeset/d6d8f46ff357/

Log:    extend any list with emptylist

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
@@ -476,6 +476,8 @@
         if self.list_is_correct_type(w_other):
             l += self.cast_from_void_star(w_other.lstorage)
             return
+        elif w_other.strategy is self.space.fromcache(EmptyListStrategy):
+            return
 
         #XXX unnecessary copy if w_other is ObjectList
         list_w = w_other.getitems()
diff --git a/pypy/objspace/std/test/test_liststrategies.py 
b/pypy/objspace/std/test/test_liststrategies.py
--- a/pypy/objspace/std/test/test_liststrategies.py
+++ b/pypy/objspace/std/test/test_liststrategies.py
@@ -174,6 +174,12 @@
         empty.extend(W_ListObject(self.space, []))
         assert isinstance(empty.strategy, EmptyListStrategy)
 
+    def test_extend_other_with_empty(self):
+        l = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), 
self.space.wrap(3)])
+        assert isinstance(l.strategy, IntegerListStrategy)
+        l.extend(W_ListObject(self.space, []))
+        assert isinstance(l.strategy, IntegerListStrategy)
+
     def test_rangelist(self):
         l = make_range_list(self.space, 1,3,7)
         assert isinstance(l.strategy, RangeListStrategy)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to