[pypy-svn] rev 616 - in pypy/trunk/src/pypy: interpreter interpreter/test module
arigo at codespeak.net
arigo at codespeak.net
Tue May 27 19:11:16 CEST 2003
Author: arigo
Date: Tue May 27 19:11:15 2003
New Revision: 616
Modified:
pypy/trunk/src/pypy/interpreter/pyframe.py
pypy/trunk/src/pypy/interpreter/test/test_executioncontext.py
pypy/trunk/src/pypy/module/builtin.py
Log:
test_executioncontext works again now
Modified: pypy/trunk/src/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/pyframe.py (original)
+++ pypy/trunk/src/pypy/interpreter/pyframe.py Tue May 27 19:11:15 2003
@@ -96,47 +96,6 @@
### frame initialization ###
- def setargs(self, w_arguments, w_kwargs=None,
- w_defaults=None, w_closure=None):
- "Initialize the frame with the given arguments tuple."
- arguments = self.decode_arguments(w_arguments, w_kwargs,
- w_defaults, w_closure)
- for i in range(len(arguments)):
- varname = self.getlocalvarname(i)
- w_varname = self.space.wrap(varname)
- w_arg = arguments[i]
- self.space.setitem(self.w_locals, w_varname, w_arg)
-
- def decode_arguments(self, w_arguments, w_kwargs, w_defaults, w_closure):
- # We cannot systematically go to the application-level (_app.py)
- # to do this dirty work, for bootstrapping reasons. So we check
- # if we are in the most simple case and if so do not go to the
- # application-level at all.
- co = self.bytecode
- if (co.co_flags & (CO_VARARGS|CO_VARKEYWORDS) == 0 and
- (w_defaults is None or not self.space.is_true(w_defaults)) and
- (w_kwargs is None or not self.space.is_true(w_kwargs)) and
- (w_closure is None or not self.space.is_true(w_closure))):
- # looks like a simple case, see if we got exactly the correct
- # number of arguments
- try:
- args = self.space.unpacktuple(w_arguments, co.co_argcount)
- except ValueError:
- pass # no
- else:
- return args # yes! fine!
- # non-trivial case. I won't do it myself.
- if w_kwargs is None: w_kwargs = self.space.newdict([])
- if w_defaults is None: w_defaults = self.space.newtuple([])
- if w_closure is None: w_closure = self.space.newtuple([])
- w_bytecode = self.space.wrap(co)
- w_arguments = self.space.gethelper(appfile).call(
- "decode_frame_arguments", [w_arguments, w_kwargs, w_defaults,
- w_closure, w_bytecode])
- # we assume that decode_frame_arguments() gives us a tuple
- # of the correct length.
- return self.space.unpacktuple(w_arguments)
-
def load_builtins(self):
# initialize self.w_builtins. This cannot be done in the '.app.py'
# file for bootstrapping reasons.
Modified: pypy/trunk/src/pypy/interpreter/test/test_executioncontext.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/test/test_executioncontext.py (original)
+++ pypy/trunk/src/pypy/interpreter/test/test_executioncontext.py Tue May 27 19:11:15 2003
@@ -10,13 +10,13 @@
# build frame
space = testsupport.objspace()
ec = executioncontext.ExecutionContext(space)
-
- bytecode = compile('def f(x): return x+1', '', 'exec').co_consts[0]
+ compile = space.builtin.compile
+ bytecode = compile(space.wrap('def f(x): return x+1'),
+ space.wrap('<string>'),
+ space.wrap('exec')).co_consts[0]
w_globals = ec.make_standard_w_globals()
- w_locals = space.newdict([])
+ w_locals = space.newdict([(space.wrap('x'), space.wrap(5))])
frame = PyFrame(space, bytecode, w_globals, w_locals)
- w_input = frame.space.wrap((5,))
- frame.setargs(w_input)
w_output = ec.eval_frame(frame)
self.assertEquals(frame.space.unwrap(w_output), 6)
Modified: pypy/trunk/src/pypy/module/builtin.py
==============================================================================
--- pypy/trunk/src/pypy/module/builtin.py (original)
+++ pypy/trunk/src/pypy/module/builtin.py Tue May 27 19:11:15 2003
@@ -13,14 +13,6 @@
__helper_appfile__ = appfile.AppFile('builtin_helper',["module"])
- # we have None!
- None = appdata(_b.None)
- False = appdata(_b.False)
- True = appdata(_b.True)
- dict = appdata(_b.dict) # XXX temporary
- tuple = appdata(_b.tuple) # XXX temporary
- int = appdata(_b.int) # XXX temporary
-
# temporary hack, until we have a real tuple type for calling
#def tuple(self, w_obj):
# lis = self.space.unpackiterable(w_obj)
@@ -165,3 +157,11 @@
unichr = appmethod(unichr)
+ # we have None! But leave these at the bottom, otherwise the default
+ # arguments of the above-defined functions will see this new None...
+ None = appdata(_b.None)
+ False = appdata(_b.False)
+ True = appdata(_b.True)
+ dict = appdata(_b.dict) # XXX temporary
+ tuple = appdata(_b.tuple) # XXX temporary
+ int = appdata(_b.int) # XXX temporary
More information about the Pypy-commit
mailing list