[pypy-commit] pypy py3k-kwonly-builtin: fixes
arigo
pypy.commits at gmail.com
Sat Aug 20 09:55:05 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: py3k-kwonly-builtin
Changeset: r86344:90e41bfacc6b
Date: 2016-08-20 15:54 +0200
http://bitbucket.org/pypy/pypy/changeset/90e41bfacc6b/
Log: fixes
diff --git a/pypy/interpreter/gateway.py b/pypy/interpreter/gateway.py
--- a/pypy/interpreter/gateway.py
+++ b/pypy/interpreter/gateway.py
@@ -985,11 +985,14 @@
continue
defaultval = self._staticdefs.get(name, NO_DEFAULT)
+ w_def = Ellipsis
if name.startswith('w_'):
assert defaultval in (NO_DEFAULT, None), (
"%s: default value for '%s' can only be None, got %r; "
"use unwrap_spec(...=WrappedDefault(default))" % (
self._code.identifier, name, defaultval))
+ if defaultval is None:
+ w_def = None
if isinstance(spec, tuple) and spec[0] is W_Root:
assert False, "use WrappedDefault"
@@ -999,10 +1002,13 @@
if defaultval is not NO_DEFAULT:
if name != '__args__' and name != 'args_w':
- if isinstance(defaultval, str) and spec not in [str]:
- w_def = space.newbytes(defaultval)
- else:
- w_def = space.wrap(defaultval)
+ if w_def is Ellipsis:
+ if isinstance(defaultval, str) and spec not in [str]:
+ w_def = space.newbytes(defaultval)
+ else:
+ w_def = space.wrap(defaultval)
+ if name.startswith('w_'):
+ name = name[2:]
alldefs_w[name] = w_def
#
# Here, 'alldefs_w' maps some argnames to their wrapped default
@@ -1022,6 +1028,7 @@
if alldefs_w:
kw_defs_w = []
for name, w_def in sorted(alldefs_w.items()):
+ assert name in sig.kwonlyargnames
w_name = space.newunicode(name.decode('utf-8'))
kw_defs_w.append((w_name, w_def))
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
@@ -759,7 +759,7 @@
@gateway.unwrap_spec(w_x = WrappedDefault(42), y=int)
def g(space, w_x, y):
never_called
- py.test.raises(AssertionError, space.wrap, gateway.interp2app_temp(g))
+ py.test.raises(KeyError, space.wrap, gateway.interp2app_temp(g))
def test_unwrap_spec_default_applevel_bug2(self):
space = self.space
More information about the pypy-commit
mailing list