[pypy-svn] r10842 - in pypy/dist/pypy/interpreter: . test
pedronis at codespeak.net
pedronis at codespeak.net
Tue Apr 19 02:00:57 CEST 2005
Author: pedronis
Date: Tue Apr 19 02:00:57 2005
New Revision: 10842
Modified:
pypy/dist/pypy/interpreter/executioncontext.py
pypy/dist/pypy/interpreter/test/test_pyframe.py
Log:
fixed bug in exception tracing, with test, discovered because the annotator in obscure ways hinted that we were
mxing W_Roots and OperationErrors, oopsy
Modified: pypy/dist/pypy/interpreter/executioncontext.py
==============================================================================
--- pypy/dist/pypy/interpreter/executioncontext.py (original)
+++ pypy/dist/pypy/interpreter/executioncontext.py Tue Apr 19 02:00:57 2005
@@ -108,12 +108,13 @@
def exception_trace(self, frame, operationerr):
"Trace function called upon OperationError."
operationerr.record_interpreter_traceback()
- exc_info = self.sys_exc_info()
- self._trace(frame, 'exception',
- exc_info)
+ space = self.space
+ w_exc_info = space.newtuple([operationerr.w_type, operationerr.w_value,
+ space.wrap(operationerr.application_traceback)])
+ self._trace(frame, 'exception', w_exc_info)
#operationerr.print_detailed_traceback(self.space)
- def sys_exc_info(self):
+ def sys_exc_info(self): # attn: the result is not the wrapped sys.exc_info() !!!
"""Implements sys.exc_info().
Return an OperationError instance or None."""
for i in range(self.framestack.depth()):
Modified: pypy/dist/pypy/interpreter/test/test_pyframe.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_pyframe.py (original)
+++ pypy/dist/pypy/interpreter/test/test_pyframe.py Tue Apr 19 02:00:57 2005
@@ -51,3 +51,23 @@
print g_frame.f_back.f_code.co_name, f_frame.f_code.co_name
sys.settrace(trace)
f()
+
+ def test_trace_exc(self):
+ import sys
+ l = []
+ def ltrace(a,b,c):
+ if b == 'exception':
+ l.append(c)
+ return ltrace
+ def trace(a,b,c): return ltrace
+ def f():
+ try:
+ raise Exception
+ except:
+ pass
+ sys.settrace(trace)
+ f()
+ sys.settrace(None)
+ assert len(l) == 1
+ assert isinstance(l[0][1], Exception)
+
More information about the Pypy-commit
mailing list