Commits

Simon Cross committed 310b0c2

Add support for copying unwrap_spec to interpindirect2app.

Comments (0)

Files changed (2)

pypy/interpreter/gateway.py

     # necessary for unique identifiers for pickling
     f.func_name = func.func_name
     if unwrap_spec is None:
-        unwrap_spec = {}
+        unwrap_spec = getattr(unbound_meth, 'unwrap_spec', {})
     else:
         assert isinstance(unwrap_spec, dict)
         unwrap_spec = unwrap_spec.copy()

pypy/interpreter/test/test_gateway.py

             def method_with_default(self, space, x=5):
                 pass
 
+            @gateway.unwrap_spec(x=int)
+            def method_with_unwrap_spec(self, space, x):
+                pass
+
         class A(BaseA):
             def method(self, space, x):
                 return space.wrap(x + 2)
             def method_with_default(self, space, x):
                 return space.wrap(x + 2)
 
+            def method_with_unwrap_spec(self, space, x):
+                return space.wrap(x + 2)
+
         class B(BaseA):
             def method(self, space, x):
                 return space.wrap(x + 1)
             def method_with_default(self, space, x):
                 return space.wrap(x + 1)
 
+            def method_with_unwrap_spec(self, space, x):
+                return space.wrap(x + 1)
+
         class FakeTypeDef(object):
             rawdict = {}
             bases = {}
         assert space.int_w(space.call_function(w_d, w_a)) == 5 + 2
         assert space.int_w(space.call_function(w_d, w_b)) == 5 + 1
 
+        meth_with_unwrap_spec = gateway.interpindirect2app(
+            BaseA.method_with_unwrap_spec)
+        w_e = space.wrap(meth_with_unwrap_spec)
+        assert space.int_w(space.call_function(w_e, w_a, space.wrap(4))) == 4 + 2
+
     def test_interp2app_unwrap_spec(self):
         space = self.space
         w = space.wrap