[pypy-commit] pypy remove-string-smm: Add support for copying unwrap_spec to interpindirect2app.
hodgestar
noreply at buildbot.pypy.org
Tue Apr 16 21:33:26 CEST 2013
Author: Simon Cross <hodgestar at gmail.com>
Branch: remove-string-smm
Changeset: r63425:1a9a9b6917f4
Date: 2013-04-16 21:31 +0200
http://bitbucket.org/pypy/pypy/changeset/1a9a9b6917f4/
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
@@ -823,7 +823,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
More information about the pypy-commit
mailing list