Author: Carl Friedrich Bolz <cfb...@gmx.de>
Branch: value-profiling
Changeset: r81923:f66ef9ad7656
Date: 2016-01-22 17:47 +0100
http://bitbucket.org/pypy/pypy/changeset/f66ef9ad7656/

Log:    fix interaction of known class lists and cpyext

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
@@ -88,6 +88,10 @@
         return space.fromcache(EmptyListStrategy)
 
     w_firstobj = list_w[0]
+    if w_firstobj is None:
+        # this is done by cpyext:
+        return space.fromcache(ObjectListStrategy)
+
     check_int_or_float = False
 
     if type(w_firstobj) is W_IntObject:
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
@@ -417,6 +417,13 @@
         assert isinstance(w_lst.strategy, SizeListStrategy)
         assert w_lst.strategy.sizehint == 13
 
+    def test_newlist_with_interplevel_None(self):
+        # needed for cpyext
+        space = self.space
+        w_lst = space.newlist([None] * 10)
+        assert w_lst.strategy._known_cls is None
+
+
     def test_find_fast_on_intlist(self, monkeypatch):
         monkeypatch.setattr(self.space, "eq_w", None)
         w = self.space.wrap
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to