[pypy-commit] pypy speedup-unpackiterable: iterator fixes, some tests, oops

fijal noreply at buildbot.pypy.org
Fri Jul 13 13:34:04 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: speedup-unpackiterable
Changeset: r56063:ed685584236b
Date: 2012-07-13 13:33 +0200
http://bitbucket.org/pypy/pypy/changeset/ed685584236b/

Log:	iterator fixes, some tests, oops

diff --git a/pypy/objspace/std/kwargsdict.py b/pypy/objspace/std/kwargsdict.py
--- a/pypy/objspace/std/kwargsdict.py
+++ b/pypy/objspace/std/kwargsdict.py
@@ -155,9 +155,9 @@
         return keys[:], values_w[:] # copy to make non-resizable
 
     def getiterkeys(self, w_dict):
-        return self.unerase(w_dict.dstorage)[0]
+        return iter(self.unerase(w_dict.dstorage)[0])
     def getitervalues(self, w_dict):
-        return self.unerase(w_dict.dstorage)[1]
+        return iter(self.unerase(w_dict.dstorage)[1])
     def getiteritems(self, w_dict):
         keys = self.unerase(w_dict.dstorage)[0]
         return iter(range(len(keys)))
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -454,6 +454,8 @@
         class E(dict):
             pass
         assert isinstance(D.fromkeys([1, 2]), E)
+        assert dict.fromkeys({"a": 2, "b": 3}) == {"a": None, "b": None}
+        assert dict.fromkeys({"a": 2, 1: 3}) == {"a": None, 1: None}
 
     def test_str_uses_repr(self):
         class D(dict):
diff --git a/pypy/objspace/std/test/test_kwargsdict.py b/pypy/objspace/std/test/test_kwargsdict.py
--- a/pypy/objspace/std/test/test_kwargsdict.py
+++ b/pypy/objspace/std/test/test_kwargsdict.py
@@ -141,3 +141,9 @@
         d = f()
         assert "EmptyKwargsDictStrategy" in self.get_strategy(d)
 
+    def test_iterator(self):
+        def f(**args):
+            return args
+
+        assert dict.fromkeys(f(a=2, b=3)) == {"a": None, "b": None}
+        assert sorted(f(a=2, b=3).itervalues()) == [2, 3]


More information about the pypy-commit mailing list