[Python-checkins] CVS: python/dist/src/Lib/test test_grammar.py,1.37,1.38
Thomas Wouters
twouters@users.sourceforge.net
Wed, 26 Sep 2001 05:43:41 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv27695/Lib/test
Modified Files:
test_grammar.py
Log Message:
Test case for SF bugs #463359 and #462937, added to test_grammar for lack of
a better place. Excessively fragile code, but at least it breaks when
something in this area changes!
Index: test_grammar.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_grammar.py,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** test_grammar.py 2001/09/21 19:22:34 1.37
--- test_grammar.py 2001/09/26 12:43:38 1.38
***************
*** 359,362 ****
--- 359,389 ----
print msg
+
+ # This test warrants an explanation. It is a test specifically for SF bugs
+ # #463359 and #462937. The bug is that a 'break' statement executed or
+ # exception raised inside a try/except inside a loop, *after* a continue
+ # statement has been executed in that loop, will cause the wrong number of
+ # arguments to be popped off the stack and the instruction pointer reset to
+ # a very small number (usually 0.) Because of this, the following test
+ # *must* written as a function, and the tracking vars *must* be function
+ # arguments with default values. Otherwise, the test will loop and loop.
+
+ print "testing continue and break in try/except in loop"
+ def test_break_continue_loop(extra_burning_oil = 1, count=0):
+ big_hippo = 2
+ while big_hippo:
+ count += 1
+ try:
+ if extra_burning_oil and big_hippo == 1:
+ extra_burning_oil -= 1
+ break
+ big_hippo -= 1
+ continue
+ except:
+ raise
+ if count > 2 or big_hippo <> 1:
+ print "continue then break in try/except in loop broken!"
+ test_break_continue_loop()
+
print 'return_stmt' # 'return' [testlist]
def g1(): return