Author: Simon Cross <[email protected]>
Branch:
Changeset: r64010:310b0c27ddc3
Date: 2013-04-16 21:31 +0200
http://bitbucket.org/pypy/pypy/changeset/310b0c27ddc3/
Log: Add support for copying unwrap_spec to interpindirect2app.
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -817,7 +817,7 @@
# 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()
diff --git a/pypy/interpreter/test/test_gateway.py
b/pypy/interpreter/test/test_gateway.py
--- a/pypy/interpreter/test/test_gateway.py
+++ b/pypy/interpreter/test/test_gateway.py
@@ -144,6 +144,10 @@
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)
@@ -151,6 +155,9 @@
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)
@@ -158,6 +165,9 @@
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 = {}
@@ -186,6 +196,11 @@
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
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit