[pypy-commit] pypy default: Test and fix. (no cookies :-)
arigo
noreply at buildbot.pypy.org
Fri Jul 12 00:13:58 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r65359:4229b0f4399f
Date: 2013-07-12 00:13 +0200
http://bitbucket.org/pypy/pypy/changeset/4229b0f4399f/
Log: Test and fix. (no cookies :-)
diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -1050,7 +1050,7 @@
else:
# general case -- "for k in o.keys(): dict.__setitem__(d, k, o[k])"
data_w = space.listview(space.call_function(w_method))
- update1_keys(space, w_dict, data_w)
+ update1_keys(space, w_dict, w_data, data_w)
@jit.look_inside_iff(lambda space, w_dict, w_data:
@@ -1074,7 +1074,7 @@
w_dict.setitem(w_key, w_value)
-def update1_keys(space, w_dict, data_w):
+def update1_keys(space, w_dict, w_data, data_w):
for w_key in data_w:
w_value = space.getitem(w_data, w_key)
w_dict.setitem(w_key, w_value)
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
@@ -367,6 +367,16 @@
d.update({'foo': 'bar'}, baz=1)
assert d == {'foo': 'bar', 'baz': 1}
+ def test_update_keys_method(self):
+ class Foo(object):
+ def keys(self):
+ return [4, 1]
+ def __getitem__(self, key):
+ return key * 10
+ d = {}
+ d.update(Foo())
+ assert d == {1: 10, 4: 40}
+
def test_values(self):
d = {1: 2, 3: 4}
vals = d.values()
More information about the pypy-commit
mailing list