[pypy-svn] r34214 - in pypy/branch/transparent-proxy/pypy/objspace/std: . test
fijal at codespeak.net
fijal at codespeak.net
Sun Nov 5 11:35:33 CET 2006
Author: fijal
Date: Sun Nov 5 11:35:32 2006
New Revision: 34214
Modified:
pypy/branch/transparent-proxy/pypy/objspace/std/model.py
pypy/branch/transparent-proxy/pypy/objspace/std/proxy_helpers.py
pypy/branch/transparent-proxy/pypy/objspace/std/proxyobject.py
pypy/branch/transparent-proxy/pypy/objspace/std/test/test_proxy_internals.py
pypy/branch/transparent-proxy/pypy/objspace/std/transparent.py
Log:
Added TypeObject. Not sure what the semantics are altough.
Modified: pypy/branch/transparent-proxy/pypy/objspace/std/model.py
==============================================================================
--- pypy/branch/transparent-proxy/pypy/objspace/std/model.py (original)
+++ pypy/branch/transparent-proxy/pypy/objspace/std/model.py Sun Nov 5 11:35:32 2006
@@ -123,6 +123,7 @@
# xxx config
self.typeorder[proxyobject.W_TransparentList] = []
self.typeorder[proxyobject.W_TransparentDict] = []
+ self.typeorder[proxyobject.W_TransparentType] = []
if config.objspace.std.withstrdict:
del self.typeorder[dictobject.W_DictObject]
Modified: pypy/branch/transparent-proxy/pypy/objspace/std/proxy_helpers.py
==============================================================================
--- pypy/branch/transparent-proxy/pypy/objspace/std/proxy_helpers.py (original)
+++ pypy/branch/transparent-proxy/pypy/objspace/std/proxy_helpers.py Sun Nov 5 11:35:32 2006
@@ -17,17 +17,17 @@
return s, '__' + mm.name + '__'
return s, mm.name
-def install_general_args_trampoline(type_, mm, is_local):
+def install_general_args_trampoline(type_, mm, is_local, op_name):
def function(space, w_transparent_list, __args__):
- args = __args__.prepend(space.wrap(mm.name))
+ args = __args__.prepend(space.wrap(op_name))
return space.call_args(w_transparent_list.w_controller, args)
function.func_name = mm.name
mm.register(function, type_)
-def install_w_args_trampoline(type_, mm, is_local):
+def install_w_args_trampoline(type_, mm, is_local, op_name):
def function(space, w_transparent_list, *args_w):
- args = Arguments(space, [space.wrap(mm.name)] + list(args_w[:-1]), w_stararg=args_w[-1])
+ args = Arguments(space, [space.wrap(op_name)] + list(args_w[:-1]), w_stararg=args_w[-1])
return space.call_args(w_transparent_list.w_controller, args)
function.func_name = mm.name
@@ -38,9 +38,9 @@
mm_name, op_name = create_mm_names(classname, mm, is_local)
if ['__args__'] == mm.argnames_after:
- return install_general_args_trampoline(type_, mm, is_local)
+ return install_general_args_trampoline(type_, mm, is_local, op_name)
if ['w_args'] == mm.argnames_after:
- return install_w_args_trampoline(type_, mm, is_local)
+ return install_w_args_trampoline(type_, mm, is_local, op_name)
assert not mm.argnames_after
# we search here for special-cased stuff
def function(space, w_transparent_list, *args_w):
Modified: pypy/branch/transparent-proxy/pypy/objspace/std/proxyobject.py
==============================================================================
--- pypy/branch/transparent-proxy/pypy/objspace/std/proxyobject.py (original)
+++ pypy/branch/transparent-proxy/pypy/objspace/std/proxyobject.py Sun Nov 5 11:35:32 2006
@@ -92,6 +92,10 @@
class W_TransparentGenerator(W_Transparent):
typedef = GeneratorIterator.typedef
+class W_TransparentType(W_TransparentObject):
+ from pypy.objspace.std.typeobject import W_TypeObject as original
+ from pypy.objspace.std.typetype import type_typedef as typedef
+
class W_TransparentList(W_TransparentObject):
from pypy.objspace.std.listobject import W_ListObject as original
from pypy.objspace.std.listtype import list_typedef as typedef
@@ -102,7 +106,8 @@
registerimplementation(W_TransparentList)
registerimplementation(W_TransparentDict)
-
+registerimplementation(W_TransparentType)
register_type(W_TransparentList)
register_type(W_TransparentDict)
+register_type(W_TransparentType)
Modified: pypy/branch/transparent-proxy/pypy/objspace/std/test/test_proxy_internals.py
==============================================================================
--- pypy/branch/transparent-proxy/pypy/objspace/std/test/test_proxy_internals.py (original)
+++ pypy/branch/transparent-proxy/pypy/objspace/std/test/test_proxy_internals.py Sun Nov 5 11:35:32 2006
@@ -95,3 +95,9 @@
e = sys.exc_info()
assert traceback.format_tb(last_tb) == traceback.format_tb(e[2])
+
+class AppTestProxyType(AppProxy):
+ def test_filetype(self):
+ f = self.get_proxy(file)
+ f("/tmp/sth", "w").write("aaa")
+ assert open("/tmp/sth").read() == "aaa"
Modified: pypy/branch/transparent-proxy/pypy/objspace/std/transparent.py
==============================================================================
--- pypy/branch/transparent-proxy/pypy/objspace/std/transparent.py (original)
+++ pypy/branch/transparent-proxy/pypy/objspace/std/transparent.py Sun Nov 5 11:35:32 2006
@@ -27,6 +27,8 @@
return W_TransparentFrame(space, w_type, w_controller)
if space.is_true(space.issubtype(w_type, space.gettypeobject(GeneratorIterator.typedef))):
return W_TransparentGenerator(space, w_type, w_controller)
+ if isinstance(w_type, W_TypeObject):
+ return W_TransparentType(space, w_type, w_controller)
if w_type.instancetypedef is space.w_object.instancetypedef:
return W_Transparent(space, w_type, w_controller)
else:
More information about the Pypy-commit
mailing list