[pypy-commit] pypy py3.5: (plan_rich, arigo) Test and fix for 'f(**d, x=5)'
arigo
pypy.commits at gmail.com
Fri Oct 14 06:08:06 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r87780:736c0f3bc6cf
Date: 2016-10-14 12:07 +0200
http://bitbucket.org/pypy/pypy/changeset/736c0f3bc6cf/
Log: (plan_rich, arigo) Test and fix for 'f(**d, x=5)'
diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py
--- a/pypy/interpreter/astcompiler/codegen.py
+++ b/pypy/interpreter/astcompiler/codegen.py
@@ -1340,8 +1340,8 @@
nsubkwargs += 1
elif nsubkwargs:
# A keyword argument and we already have a dict.
+ kw.value.walkabout(self)
self.load_const(self.space.wrap(kw.arg.decode('utf-8')))
- kw.value.walkabout(self)
nseen += 1
else:
# keyword argument
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1405,7 +1405,7 @@
w_key = iterator.next_key()
if w_key is None:
break
- if not isinstance(w_key, space.UnicodeObjectCls):
+ if not space.isinstance_w(w_key, space.w_unicode):
err_fun = self.peekvalue(num_maps + function_location-1)
raise oefmt(space.w_TypeError,
"%N%s keywords must be strings", err_fun,
diff --git a/pypy/interpreter/test/test_argument.py b/pypy/interpreter/test/test_argument.py
--- a/pypy/interpreter/test/test_argument.py
+++ b/pypy/interpreter/test/test_argument.py
@@ -871,3 +871,10 @@
assert str(e) == "myerror"
else:
assert False, "Expected TypeError"
+
+ def test_keyword_arg_after_keywords_dict(self):
+ """
+ def f(x, y):
+ return (x, y)
+ assert f(**{'x': 5}, y=6) == (5, 6)
+ """
More information about the pypy-commit
mailing list