[pypy-svn] r34642 - in pypy/dist/pypy/objspace/std: . test
fijal at codespeak.net
fijal at codespeak.net
Wed Nov 15 22:21:06 CET 2006
Author: fijal
Date: Wed Nov 15 22:21:03 2006
New Revision: 34642
Modified:
pypy/dist/pypy/objspace/std/objspace.py
pypy/dist/pypy/objspace/std/proxyobject.py
pypy/dist/pypy/objspace/std/test/test_proxy_internals.py
pypy/dist/pypy/objspace/std/transparent.py
Log:
Added check for controller (in pypymagic). I did not find a good name, please replace it if you feel like finding better.
Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py (original)
+++ pypy/dist/pypy/objspace/std/objspace.py Wed Nov 15 22:21:03 2006
@@ -135,10 +135,12 @@
# Adding transparent proxy call
if self.config.objspace.std.withtproxy:
w_pypymagic = self.getbuiltinmodule("pypymagic")
- from pypy.objspace.std.transparent import app_proxy
+ from pypy.objspace.std.transparent import app_proxy, app_proxy_controller
self.setattr(w_pypymagic, self.wrap('transparent_proxy'),
self.wrap(app_proxy))
+ self.setattr(w_pypymagic, self.wrap('get_transparent_controller'),
+ self.wrap(app_proxy_controller))
def enable_old_style_classes_as_default_metaclass(self):
self.setitem(self.builtin.w_dict, self.wrap('__metaclass__'), self.w_classobj)
Modified: pypy/dist/pypy/objspace/std/proxyobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/proxyobject.py (original)
+++ pypy/dist/pypy/objspace/std/proxyobject.py Wed Nov 15 22:21:03 2006
@@ -68,7 +68,7 @@
def setdict(self, space, w_dict):
if not self.setdictvalue(space, space.wrap('__dict__'), w_dict):
baseobjspace.W_Root.setdict(self, space, w_dict)
-
+
W_Transparent.__name__ = name
return W_Transparent
Modified: pypy/dist/pypy/objspace/std/test/test_proxy_internals.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_proxy_internals.py (original)
+++ pypy/dist/pypy/objspace/std/test/test_proxy_internals.py Wed Nov 15 22:21:03 2006
@@ -101,6 +101,14 @@
e = sys.exc_info()
assert traceback.format_tb(last_tb) == traceback.format_tb(e[2])
+
+ def test_proxy_get(self):
+ from pypymagic import transparent_proxy, get_transparent_controller
+ l = [1,2,3]
+ def f(name, *args, **kwargs):
+ return getattr(l, name)(*args, **kwargs)
+ lst = transparent_proxy(list, f)
+ assert get_transparent_controller(lst) is f
class DONTAppTestProxyType(AppProxy):
def test_filetype(self):
Modified: pypy/dist/pypy/objspace/std/transparent.py
==============================================================================
--- pypy/dist/pypy/objspace/std/transparent.py (original)
+++ pypy/dist/pypy/objspace/std/transparent.py Wed Nov 15 22:21:03 2006
@@ -35,5 +35,12 @@
raise OperationError(space.w_TypeError, space.wrap("Object type %s could not "\
"be wrapped (YET)" % w_type.getname(space, "?")))
+def proxy_controller(space, w_object):
+ if (not isinstance(w_object, W_Transparent)) and \
+ (not isinstance(w_object, W_TransparentObject)):
+ return None
+ return w_object.w_controller
+
app_proxy = gateway.interp2app(proxy, unwrap_spec=[gateway.ObjSpace, gateway.W_Root, \
gateway.W_Root])
+app_proxy_controller = gateway.interp2app(proxy_controller, unwrap_spec=[gateway.ObjSpace, gateway.W_Root])
More information about the Pypy-commit
mailing list