[pypy-commit] pypy py3k: we still need to special case unwrapped defaults too, now w/ a test
pjenvey
noreply at buildbot.pypy.org
Wed Oct 17 23:38:18 CEST 2012
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r58189:4ab357f7d06d
Date: 2012-10-17 10:39 -0700
http://bitbucket.org/pypy/pypy/changeset/4ab357f7d06d/
Log: we still need to special case unwrapped defaults too, now w/ a test
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -852,7 +852,8 @@
def _getdefaults(self, space):
"NOT_RPYTHON"
defs_w = []
- for name, defaultval in self._staticdefs:
+ unwrap_spec = self._code._unwrap_spec[-len(self._staticdefs):]
+ for i, (name, defaultval) in enumerate(self._staticdefs):
if name.startswith('w_'):
assert defaultval is None, (
"%s: default value for '%s' can only be None; "
@@ -860,7 +861,11 @@
self._code.identifier, name))
defs_w.append(None)
else:
- defs_w.append(space.wrap(defaultval))
+ spec = unwrap_spec[i]
+ if isinstance(defaultval, str) and spec not in [str]:
+ defs_w.append(space.wrapbytes(defaultval))
+ else:
+ defs_w.append(space.wrap(defaultval))
if self._code._unwrap_spec:
UNDEFINED = object()
alldefs_w = [UNDEFINED] * len(self._code.sig[0])
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
@@ -611,6 +611,16 @@
never_called
py.test.raises(AssertionError, space.wrap, gateway.interp2app_temp(g))
+ def test_unwrap_spec_default_bytes(self):
+ space = self.space
+ @gateway.unwrap_spec(s='bufferstr')
+ def g(space, s=''):
+ return space.wrap(type(s) is str)
+ w_g = space.wrap(gateway.interp2app_temp(g))
+ args = argument.Arguments(space, [])
+ w_res = space.call_args(w_g, args)
+ assert space.eq_w(w_res, space.w_True)
+
def test_unwrap_spec_default_applevel_bytes(self):
space = self.space
@gateway.unwrap_spec(w_x=WrappedDefault('foo'))
More information about the pypy-commit
mailing list