[pypy-svn] r34200 - in pypy/branch/transparent-proxy/pypy: interpreter objspace/std objspace/std/test
fijal at codespeak.net
fijal at codespeak.net
Sat Nov 4 17:58:11 CET 2006
Author: fijal
Date: Sat Nov 4 17:58:08 2006
New Revision: 34200
Modified:
pypy/branch/transparent-proxy/pypy/interpreter/pyopcode.py
pypy/branch/transparent-proxy/pypy/objspace/std/proxyobject.py
pypy/branch/transparent-proxy/pypy/objspace/std/test/test_proxy_internals.py
Log:
(pedronis, fijal) - Basics of traceback now works.
Modified: pypy/branch/transparent-proxy/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/branch/transparent-proxy/pypy/interpreter/pyopcode.py (original)
+++ pypy/branch/transparent-proxy/pypy/interpreter/pyopcode.py Sat Nov 4 17:58:08 2006
@@ -351,7 +351,8 @@
raise operror
else:
tb = space.interpclass_w(w_traceback)
- if not isinstance(tb, pytraceback.PyTraceback):
+ if tb is None or not space.is_true(space.isinstance(tb,
+ space.gettypeobject(pytraceback.PyTraceback.typedef))):
raise OperationError(space.w_TypeError,
space.wrap("raise: arg 3 must be a traceback or None"))
operror.application_traceback = tb
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 Sat Nov 4 17:58:08 2006
@@ -11,61 +11,72 @@
# def __init__(self, w_controller):
# self.controller = w_controller
-class W_Transparent(W_Object):
- def __init__(self, space, w_type, w_controller):
- self.w_type = w_type
- self.w_controller = w_controller
- self.space = space
-
- def getclass(self, space):
- return self.w_type
-
- def setclass(self, space, w_subtype):
- raise OperationError(space.w_TypeError,
- space.wrap("You cannot override __class__ for transparent proxies"))
-
- def getdictvalue(self, space, w_attr):
- try:
- return space.call_function(self.w_controller, space.wrap('__getattribute__'),
- w_attr)
- except OperationError, e:
- if not e.match(space, space.w_AttributeError):
- raise
- return None
-
- def setdictvalue(self, space, w_attr, w_value):
- try:
- space.call_function(self.w_controller, space.wrap('__setattr__'),
- w_attr, w_value)
- return True
- except OperationError, e:
- if not e.match(space, space.w_AttributeError):
- raise
- return False
-
- def deldictvalue(self, space, w_attr):
- try:
- space.call_function(self.w_controller, space.wrap('__delattr__'),
- w_attr)
- return True
- except OperationError, e:
- if not e.match(space, space.w_AttributeError):
- raise
- return False
-
- def getdict(self):
- return self.getdictvalue(self.space, self.space.wrap('__dict__'))
-
- def setdict(self, space, w_dict):
- if not self.setdictvalue(space, space.wrap('__dict__'), w_dict):
- baseobjspace.W_Root.setdict(self, space, w_dict)
-
- def descr_call_mismatch(self, space, name, reqcls, args):
- _, args = args.popfirst()
- args = args.prepend(space.wrap(name))
- return space.call_args(self.w_controller, args)
+#class W_TransparentWrappable(Wrappable):
- from pypy.objspace.std.objecttype import object_typedef as typedef
+def transparent_class(name, BaseCls):
+
+ class W_Transparent(BaseCls):
+ def __init__(self, space, w_type, w_controller):
+ self.w_type = w_type
+ self.w_controller = w_controller
+ self.space = space
+
+ def descr_call_mismatch(self, space, name, reqcls, args):
+ _, args = args.popfirst()
+ args = args.prepend(space.wrap(name))
+ return space.call_args(self.w_controller, args)
+
+ def getclass(self, space):
+ return self.w_type
+
+ def setclass(self, space, w_subtype):
+ raise OperationError(space.w_TypeError,
+ space.wrap("You cannot override __class__ for transparent proxies"))
+
+ def getdictvalue(self, space, w_attr):
+ try:
+ return space.call_function(self.w_controller, space.wrap('__getattribute__'),
+ w_attr)
+ except OperationError, e:
+ if not e.match(space, space.w_AttributeError):
+ raise
+ return None
+
+ def setdictvalue(self, space, w_attr, w_value):
+ try:
+ space.call_function(self.w_controller, space.wrap('__setattr__'),
+ w_attr, w_value)
+ return True
+ except OperationError, e:
+ if not e.match(space, space.w_AttributeError):
+ raise
+ return False
+
+ def deldictvalue(self, space, w_attr):
+ try:
+ space.call_function(self.w_controller, space.wrap('__delattr__'),
+ w_attr)
+ return True
+ except OperationError, e:
+ if not e.match(space, space.w_AttributeError):
+ raise
+ return False
+
+ def getdict(self):
+ return self.getdictvalue(self.space, self.space.wrap('__dict__'))
+
+ 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
+
+W_Transparent = transparent_class('W_Transparent', Wrappable)
+W_TransparentObject = transparent_class('W_TransparentObject', W_Object)
+
+from pypy.objspace.std.objecttype import object_typedef
+W_TransparentObject.typedef = object_typedef
class W_TransparentFunction(W_Transparent):
from pypy.interpreter.function import Function
@@ -74,12 +85,12 @@
class W_TransparentTraceback(W_Transparent):
from pypy.interpreter.pytraceback import PyTraceback
typedef = PyTraceback.typedef
-
-class W_TransparentList(W_Transparent):
+
+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
-
-class W_TransparentDict(W_Transparent):
+
+class W_TransparentDict(W_TransparentObject):
from pypy.objspace.std.dictobject import W_DictObject as original
from pypy.objspace.std.dicttype import dict_typedef as typedef
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 Sat Nov 4 17:58:08 2006
@@ -27,7 +27,7 @@
assert tb.tb_frame is e[2].tb_frame
def test_traceback_reraise(self):
- py.test.skip("Not implemented yet")
+ #skip("Not implemented yet")
try:
1/0
except:
@@ -37,3 +37,5 @@
tb = self.get_proxy(e[2])
raises(ZeroDivisionError, "raise e[0], e[1], tb")
raises(ZeroDivisionError, "raise e[0], self.get_proxy(e[1]), tb")
+ import traceback
+ assert len(traceback.format_tb(tb)) == 1
More information about the Pypy-commit
mailing list