[pypy-commit] pypy py3.5-async: Fix test for build_set_unpack, add test for build_map_unpack_with_call, fix getFuncDesc
raffael_t
pypy.commits at gmail.com
Sat Aug 6 14:41:00 EDT 2016
Author: Raffael Tfirst <raffael.tfirst at gmail.com>
Branch: py3.5-async
Changeset: r86049:7f49d892fb4d
Date: 2016-08-06 20:40 +0200
http://bitbucket.org/pypy/pypy/changeset/7f49d892fb4d/
Log: Fix test for build_set_unpack, add test for
build_map_unpack_with_call, fix getFuncDesc
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1374,10 +1374,10 @@
w_sum = self.unpack_helper(itemcount, next_instr)
self.pushvalue(self.space.newlist(w_sum))
- def getFuncDesc(func):
- if self.space.type(aaa).name.decode('utf-8') == 'method':
+ def getFuncDesc(self, func):
+ if self.space.type(func).name.decode('utf-8') == 'method':
return "()"
- elif self.space.type(aaa).name.decode('utf-8') == 'function':
+ elif self.space.type(func).name.decode('utf-8') == 'function':
return "()"
else:
return " object";
@@ -1403,7 +1403,7 @@
err_fun = self.peekvalue(num_maps + function_location-1)
err_arg = self.space.unicode_w(keys.getitem(j))
raise oefmt(self.space.w_TypeError,
- "%N%s got multiple values for keyword argument %s", err_fun, getFuncDesc(err_fun), err_arg)
+ "%N%s got multiple values for keyword argument '%s'", err_fun, self.getFuncDesc(err_fun), err_arg)
self.space.call_method(w_dict, 'update', w_item)
while num_maps != 0:
self.popvalue()
diff --git a/pypy/interpreter/test/test_interpreter.py b/pypy/interpreter/test/test_interpreter.py
--- a/pypy/interpreter/test/test_interpreter.py
+++ b/pypy/interpreter/test/test_interpreter.py
@@ -261,7 +261,10 @@
code = """ def f():
return {*range(4), 4, *(5, 6, 7)}
"""
- assert self.codetest(code, "f", []) == {0, 1, 2, 3, 4, 5, 6, 7}
+ space = self.space
+ res = self.codetest(code, "f", [])
+ l_res = space.call_function(space.w_list, res)
+ assert space.unwrap(l_res) == [0, 1, 2, 3, 4, 5, 6, 7]
def test_build_tuple_unpack(self):
code = """ def f():
@@ -286,6 +289,30 @@
res = self.codetest(code, 'g', [])
assert "TypeError:" in res
assert "'tuple' object is not a mapping" in res
+
+ def test_build_map_unpack_with_call(self):
+ code = """
+ def f(a,b,c,d):
+ return a+b,c+d
+ def g1():
+ return f(**{'a': 1, 'c': 3}, **{'b': 2, 'd': 4})
+ def g2():
+ return f(**{'a': 1, 'c': 3}, **[])
+ def g3():
+ return f(**{'a': 1, 'c': 3}, **{1: 3})
+ def g4():
+ return f(**{'a': 1, 'c': 3}, **{'a': 2})
+ """
+ assert self.codetest(code, "g1", []) == (3, 7)
+ resg2 = self.codetest(code, 'g2', [])
+ assert "TypeError:" in resg2
+ assert "'list' object is not a mapping" in resg2
+ resg3 = self.codetest(code, 'g3', [])
+ assert "TypeError:" in resg3
+ assert "keywords must be strings" in resg3
+ resg4 = self.codetest(code, 'g4', [])
+ assert "TypeError:" in resg4
+ assert "f() got multiple values for keyword argument 'a'" in resg4
class AppTestInterpreter:
More information about the pypy-commit
mailing list