[pypy-svn] r48621 - in pypy/branch/more-unicode-improvements/pypy/interpreter: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Nov 12 23:45:55 CET 2007


Author: cfbolz
Date: Mon Nov 12 23:45:55 2007
New Revision: 48621

Modified:
   pypy/branch/more-unicode-improvements/pypy/interpreter/gateway.py
   pypy/branch/more-unicode-improvements/pypy/interpreter/test/test_gateway.py
Log:
allow unicode in the unwrap_spec


Modified: pypy/branch/more-unicode-improvements/pypy/interpreter/gateway.py
==============================================================================
--- pypy/branch/more-unicode-improvements/pypy/interpreter/gateway.py	(original)
+++ pypy/branch/more-unicode-improvements/pypy/interpreter/gateway.py	Mon Nov 12 23:45:55 2007
@@ -164,7 +164,7 @@
         app_sig.varargname = argname[2:]
 
     def visit__object(self, typ, app_sig):
-        if typ not in (int, str, float, r_longlong):
+        if typ not in (int, str, float, unicode, r_longlong):
             assert False, "unsupported basic type in unwrap_spec"
         self.checked_space_method(typ.__name__, app_sig)
 
@@ -210,8 +210,8 @@
         self.run_args.append(self.scopenext())
 
     def visit__object(self, typ):
-        if typ not in (int, str, float, r_longlong):
-            assert False, "unsupported basic type in uwnrap_spec"
+        if typ not in (int, str, float, unicode, r_longlong):
+            assert False, "unsupported basic type in unwrap_spec"
         if typ is r_int is r_longlong:
             name = 'r_longlong'
         else:
@@ -327,7 +327,7 @@
         raise FastFuncNotSupported
 
     def visit__object(self, typ):
-        if typ not in (int, str, float, r_longlong):
+        if typ not in (int, str, float, unicode, r_longlong):
             assert False, "unsupported basic type in uwnrap_spec"
         self.unwrap.append("space.%s_w(%s)" % (typ.__name__,
                                                self.nextarg()))

Modified: pypy/branch/more-unicode-improvements/pypy/interpreter/test/test_gateway.py
==============================================================================
--- pypy/branch/more-unicode-improvements/pypy/interpreter/test/test_gateway.py	(original)
+++ pypy/branch/more-unicode-improvements/pypy/interpreter/test/test_gateway.py	Mon Nov 12 23:45:55 2007
@@ -287,6 +287,27 @@
         raises(gateway.OperationError,space.call_function,w_app_g3_f,w(None))
         raises(gateway.OperationError,space.call_function,w_app_g3_f,w("foo"))
 
+    def test_interp2app_unwrap_spec_unicode(self):
+        space = self.space
+        w = space.wrap
+        def g3_u(space, uni):
+            return space.wrap(len(uni))
+        app_g3_u = gateway.interp2app_temp(g3_u,
+                                         unwrap_spec=[gateway.ObjSpace,
+                                                      unicode])
+        w_app_g3_u = space.wrap(app_g3_u)
+        assert self.space.eq_w(
+            space.call_function(w_app_g3_u, w(u"foo")),
+            w(3))
+        assert self.space.eq_w(
+            space.call_function(w_app_g3_u, w("baz")),
+            w(3))
+        raises(gateway.OperationError, space.call_function, w_app_g3_u,
+               w(None))
+        raises(gateway.OperationError, space.call_function, w_app_g3_u,
+               w(42))
+
+
     def test_interp2app_unwrap_spec_func(self):
         space = self.space
         w = space.wrap



More information about the Pypy-commit mailing list