Armin Rigo's fix & test for

[ 729622 ] line tracing hook errors

with massaging from me to integrate test into test suite.
This commit is contained in:
Michael W. Hudson 2003-04-29 16:18:47 +00:00
parent 572f5233f0
commit 58ee2af48e
2 changed files with 32 additions and 10 deletions

View file

@ -221,6 +221,27 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
def test_exception(self):
self.run_test_for_event('exception')
def test_trash_stack(self):
def f():
for i in range(5):
print i # line tracing will raise an exception at this line
def g(frame, why, extra):
if (why == 'line' and
frame.f_lineno == f.func_code.co_firstlineno + 2):
raise RuntimeError, "i am crashing"
return g
sys.settrace(g)
try:
f()
except RuntimeError:
# the test is really that this doesn't segfault:
import gc
gc.collect()
else:
self.fail("exception not propagated")
# 'Jump' tests: assigning to frame.f_lineno within a trace function
# moves the execution position - it's how debuggers implement a Jump