[pypy-commit] pypy py3k: flow objspace support for unicode keyword arguments

antocuni noreply at buildbot.pypy.org
Fri Aug 17 21:59:43 CEST 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r56739:0e507c161193
Date: 2012-08-17 10:46 +0200
http://bitbucket.org/pypy/pypy/changeset/0e507c161193/

Log:	flow objspace support for unicode keyword arguments

diff --git a/pypy/objspace/flow/objspace.py b/pypy/objspace/flow/objspace.py
--- a/pypy/objspace/flow/objspace.py
+++ b/pypy/objspace/flow/objspace.py
@@ -165,6 +165,17 @@
             return val
         return self.unwrap(w_obj)                                
 
+    def unicode_w(self, w_obj):
+        if isinstance(w_obj, Constant):
+            val = w_obj.value
+            if type(val) is str:
+                return val.decode('ascii')
+            elif type(val) is unicode:
+                return val
+            else:
+                raise TypeError("expected unicode: " + repr(w_obj))
+        return self.unwrap(w_obj)                                
+
     def float_w(self, w_obj):
         if isinstance(w_obj, Constant):
             val = w_obj.value
diff --git a/pypy/objspace/flow/test/test_objspace.py b/pypy/objspace/flow/test/test_objspace.py
--- a/pypy/objspace/flow/test/test_objspace.py
+++ b/pypy/objspace/flow/test/test_objspace.py
@@ -665,6 +665,13 @@
             for op in block.operations:
                 assert not op.opname == "call_args"
 
+    def test_keyword_arguments(self):
+        def g(a, b):
+            pass
+        def f():
+            return g(a=1, b=2)
+        self.codetest(f)
+
     def test_catch_importerror_1(self):
         def f():
             try:


More information about the pypy-commit mailing list