[pypy-svn] r64501 - in pypy/trunk/pypy: interpreter objspace objspace/std objspace/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Tue Apr 21 12:45:55 CEST 2009
Author: cfbolz
Date: Tue Apr 21 12:45:54 2009
New Revision: 64501
Modified:
pypy/trunk/pypy/interpreter/baseobjspace.py
pypy/trunk/pypy/objspace/std/stdtypedef.py
pypy/trunk/pypy/objspace/test/test_thunkobjspace.py
pypy/trunk/pypy/objspace/thunk.py
Log:
fix the test by adding a new space method resolve_target (that just returns its
argument, by default) that the thunk obj space overrides to act like force. This
method is called on the sliced-on argument by std objspace multimethods.
Modified: pypy/trunk/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/trunk/pypy/interpreter/baseobjspace.py (original)
+++ pypy/trunk/pypy/interpreter/baseobjspace.py Tue Apr 21 12:45:54 2009
@@ -1017,6 +1017,11 @@
warnings.warn(msg, warningcls, stacklevel=2)
""")
+ def resolve_target(self, w_obj):
+ """ A space method that can be used by special object spaces (like
+ thunk) to replace an object by another. """
+ return w_obj
+
class AppExecCache(SpaceCache):
def build(cache, source):
Modified: pypy/trunk/pypy/objspace/std/stdtypedef.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/stdtypedef.py (original)
+++ pypy/trunk/pypy/objspace/std/stdtypedef.py Tue Apr 21 12:45:54 2009
@@ -185,6 +185,12 @@
dest.append(expr_arg)
renaming = ', '.join(dest) +" = "+', '.join(src)
+ # add a call to resolve_target to give the thunk space a chance to replace
+ # the thing with something else
+ offset = len(multimethod.argnames_before)
+ renaming += "; %s = space.resolve_target(%s)" % (
+ exprargs[selfindex+offset], exprargs[selfindex+offset])
+
if allow_NotImplemented_results and (len(multimethod.specialnames) > 1 or
multimethod.name.startswith('inplace_')):
# turn FailedToImplement into NotImplemented
Modified: pypy/trunk/pypy/objspace/test/test_thunkobjspace.py
==============================================================================
--- pypy/trunk/pypy/objspace/test/test_thunkobjspace.py (original)
+++ pypy/trunk/pypy/objspace/test/test_thunkobjspace.py Tue Apr 21 12:45:54 2009
@@ -164,10 +164,9 @@
class AppTest_ThunkCallMethod(AppTest_Thunk):
def setup_class(cls):
- cls.space = gettestobjspace('thunk', CALL_METHOD=True)
+ cls.space = gettestobjspace('thunk', CALL_METHOD=True, multimethods='doubledispatch')
def test_method_call(self):
- skip('fix me')
from __pypy__ import thunk
d = {}
# need the method to use the pypy compiler
@@ -180,3 +179,9 @@
l = thunk(d['f'], 10)
d['g'](l)
assert l == [10, 1]
+
+
+class AppTest_ThunkCallMethodMRD(AppTest_ThunkCallMethod):
+
+ def setup_class(cls):
+ cls.space = gettestobjspace('thunk', CALL_METHOD=True, multimethods='mrd')
Modified: pypy/trunk/pypy/objspace/thunk.py
==============================================================================
--- pypy/trunk/pypy/objspace/thunk.py (original)
+++ pypy/trunk/pypy/objspace/thunk.py Tue Apr 21 12:45:54 2009
@@ -210,6 +210,7 @@
from pypy.objspace import std
space = std.Space(*args, **kwds)
patch_space_in_place(space, 'thunk', proxymaker)
+ space.resolve_target = lambda w_arg: _force(space, w_arg)
w___pypy__ = space.getbuiltinmodule("__pypy__")
space.w_fn_thunk = space.wrap(app_thunk)
space.setattr(w___pypy__, space.wrap('thunk'),
More information about the Pypy-commit
mailing list