[pypy-svn] r26351 - in pypy/dist/pypy/objspace/cpy: . test
arigo at codespeak.net
arigo at codespeak.net
Wed Apr 26 10:16:20 CEST 2006
Author: arigo
Date: Wed Apr 26 10:16:19 2006
New Revision: 26351
Modified:
pypy/dist/pypy/objspace/cpy/test/test_wrappable.py
pypy/dist/pypy/objspace/cpy/wrappable.py
Log:
Take more care about argument names, as they are used when called with
keywords.
Modified: pypy/dist/pypy/objspace/cpy/test/test_wrappable.py
==============================================================================
--- pypy/dist/pypy/objspace/cpy/test/test_wrappable.py (original)
+++ pypy/dist/pypy/objspace/cpy/test/test_wrappable.py Wed Apr 26 10:16:19 2006
@@ -1,19 +1,31 @@
from pypy.objspace.cpy.objspace import CPyObjSpace
from pypy.interpreter.function import BuiltinFunction
from pypy.interpreter.gateway import interp2app, ObjSpace, W_Root
+from pypy.interpreter.argument import Arguments
-def test_builtin_function():
- def entrypoint(space, w_x):
- x = space.int_w(w_x)
- result = x * 7
- return space.wrap(result)
- entrypoint.unwrap_spec = [ObjSpace, W_Root]
+def entrypoint1(space, w_x):
+ x = space.int_w(w_x)
+ result = x * 7
+ return space.wrap(result)
+entrypoint1.unwrap_spec = [ObjSpace, W_Root]
+
+def test_builtin_function():
space = CPyObjSpace()
- func = interp2app(entrypoint).__spacebind__(space)
+ func = interp2app(entrypoint1).__spacebind__(space)
bltin = BuiltinFunction(func)
w_entrypoint = space.wrap(bltin)
w_result = space.call_function(w_entrypoint, space.wrap(-2))
result = space.int_w(w_result)
assert result == -14
+
+def test_builtin_function_keywords():
+ space = CPyObjSpace()
+ func = interp2app(entrypoint1).__spacebind__(space)
+ bltin = BuiltinFunction(func)
+ w_entrypoint = space.wrap(bltin)
+ args = Arguments(space, [], {'x': space.wrap(-3)})
+ w_result = space.call_args(w_entrypoint, args)
+ result = space.int_w(w_result)
+ assert result == -21
Modified: pypy/dist/pypy/objspace/cpy/wrappable.py
==============================================================================
--- pypy/dist/pypy/objspace/cpy/wrappable.py (original)
+++ pypy/dist/pypy/objspace/cpy/wrappable.py Wed Apr 26 10:16:19 2006
@@ -22,7 +22,7 @@
def visit__W_Root(self, el, orig_sig, tramp):
argname = orig_sig.next_arg()
assert argname.startswith('w_')
- basename = 'o_' + argname[2:]
+ basename = argname[2:]
tramp.inputargs.append(basename)
tramp.wrappings.append('%s = ___W_Object(%s)' % (argname, basename))
tramp.passedargs.append(argname)
@@ -33,11 +33,10 @@
float: 'XXX'}
argname = orig_sig.next_arg()
assert not argname.startswith('w_')
- basename = 'o_' + argname
- tramp.inputargs.append(basename)
+ tramp.inputargs.append(argname)
tramp.wrappings.append('%s = %s(%s)' % (argname,
convertermap[el],
- basename))
+ argname))
tramp.passedargs.append(argname)
More information about the Pypy-commit
mailing list