[Python-checkins] python/dist/src/Lib/test test_trace.py,1.7,1.8

mwh@users.sourceforge.net mwh@users.sourceforge.net
Tue, 29 Apr 2003 09:18:53 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv24164/Lib/test

Modified Files:
	test_trace.py 
Log Message:
Armin Rigo's fix & test for

[ 729622 ] line tracing hook errors

with massaging from me to integrate test into test suite.


Index: test_trace.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_trace.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** test_trace.py	17 Dec 2002 16:15:22 -0000	1.7
--- test_trace.py	29 Apr 2003 16:18:47 -0000	1.8
***************
*** 222,225 ****
--- 222,246 ----
          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