Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: kill-flowobjspace
Changeset: r60525:352b1a959932
Date: 2013-01-27 16:40 +0000
http://bitbucket.org/pypy/pypy/changeset/352b1a959932/

Log:    raise FlowingError on **-unpacking

diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -971,6 +971,8 @@
         self.pushvalue(last_val)
 
     def call_function(self, oparg, w_star=None, w_starstar=None):
+        if w_starstar is not None:
+            raise FlowingError(self, "Dict-unpacking is not RPython")
         n_arguments = oparg & 0xff
         n_keywords = (oparg>>8) & 0xff
         if n_keywords:
diff --git a/rpython/flowspace/test/test_objspace.py 
b/rpython/flowspace/test/test_objspace.py
--- a/rpython/flowspace/test/test_objspace.py
+++ b/rpython/flowspace/test/test_objspace.py
@@ -699,6 +699,23 @@
             for op in block.operations:
                 assert not op.opname == "call_args"
 
+    def test_starstar_call(self):
+        """Check that CALL_FUNCTION_KW and CALL_FUNCTION_VAR_KW raise a
+        useful error.
+        """
+        def g(a, b, c):
+            return a*b*c
+        def f1():
+            return g(**{'a':0})
+        with py.test.raises(FlowingError) as excinfo:
+            graph = self.codetest(f1)
+        assert 'Dict-unpacking' in str(excinfo.value)
+        def f2():
+            return g(*(0,), **{'c':3})
+        with py.test.raises(FlowingError) as excinfo:
+            graph = self.codetest(f2)
+        assert 'Dict-unpackinga' in str(excinfo.value)
+
     def test_catch_importerror_1(self):
         def f():
             try:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to