Commits

Carl Friedrich Bolz  committed af8f16a

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.

  • Participants
  • Parent commits c5458c2
  • Branches trunk

Comments (0)

Files changed (4)

File pypy/interpreter/baseobjspace.py

             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):

File pypy/objspace/std/stdtypedef.py

             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

File pypy/objspace/test/test_thunkobjspace.py

 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
         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')

File pypy/objspace/thunk.py

     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'),