diff options
Diffstat (limited to 'Demo/metaclasses/Trace.py')
-rw-r--r-- | Demo/metaclasses/Trace.py | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/Demo/metaclasses/Trace.py b/Demo/metaclasses/Trace.py index 97fda56..d211d17 100644 --- a/Demo/metaclasses/Trace.py +++ b/Demo/metaclasses/Trace.py @@ -35,7 +35,7 @@ class TraceMetaClass: return base.__getattr__(name) except AttributeError: pass - raise AttributeError, name + raise AttributeError(name) def __setattr__(self, name, value): if not self.__inited: @@ -69,7 +69,7 @@ class TracingInstance: try: raw = self.__class.__getattr__(name) except AttributeError: - raise AttributeError, name + raise AttributeError(name) if type(raw) != types.FunctionType: return raw # It's a function @@ -99,7 +99,7 @@ class TracingWrapper(NotTracingWrapper): self.inst.__trace_call__(self.inst.__trace_output__, "returning from %s with exception %s: %s", self.__name__, t, v) - raise t, v, tb + raise t(v).with_traceback(tb) else: self.inst.__trace_call__(self.inst.__trace_output__, "returning from %s with value %s", @@ -117,28 +117,28 @@ def _test(): def m2(self, y): return self.x + y __trace_output__ = sys.stdout class D(C): - def m2(self, y): print "D.m2(%r)" % (y,); return C.m2(self, y) + def m2(self, y): print("D.m2(%r)" % (y,)); return C.m2(self, y) __trace_output__ = None x = C(4321) - print x - print x.x - print x.m1(100) - print x.m1(10) - print x.m2(33) - print x.m1(5) - print x.m2(4000) - print x.x - - print C.__init__ - print C.m2 - print D.__init__ - print D.m2 + print(x) + print(x.x) + print(x.m1(100)) + print(x.m1(10)) + print(x.m2(33)) + print(x.m1(5)) + print(x.m2(4000)) + print(x.x) + + print(C.__init__) + print(C.m2) + print(D.__init__) + print(D.m2) y = D() - print y - print y.m1(10) - print y.m2(100) - print y.x + print(y) + print(y.m1(10)) + print(y.m2(100)) + print(y.x) if __name__ == '__main__': _test() |