File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ break_stmt
3232continue_stmt
3333continue + try/except ok
3434continue + try/finally ok
35+ testing continue and break in try/except in loop
3536return_stmt
3637raise_stmt
3738import_stmt
Original file line number Diff line number Diff line change @@ -358,6 +358,33 @@ def tellme(file=None):
358358 msg = "continue + try/finally ok"
359359print msg
360360
361+
362+ # This test warrants an explanation. It is a test specifically for SF bugs
363+ # #463359 and #462937. The bug is that a 'break' statement executed or
364+ # exception raised inside a try/except inside a loop, *after* a continue
365+ # statement has been executed in that loop, will cause the wrong number of
366+ # arguments to be popped off the stack and the instruction pointer reset to
367+ # a very small number (usually 0.) Because of this, the following test
368+ # *must* written as a function, and the tracking vars *must* be function
369+ # arguments with default values. Otherwise, the test will loop and loop.
370+
371+ print "testing continue and break in try/except in loop"
372+ def test_break_continue_loop (extra_burning_oil = 1 , count = 0 ):
373+ big_hippo = 2
374+ while big_hippo :
375+ count += 1
376+ try :
377+ if extra_burning_oil and big_hippo == 1 :
378+ extra_burning_oil -= 1
379+ break
380+ big_hippo -= 1
381+ continue
382+ except :
383+ raise
384+ if count > 2 or big_hippo <> 1 :
385+ print "continue then break in try/except in loop broken!"
386+ test_break_continue_loop ()
387+
361388print 'return_stmt' # 'return' [testlist]
362389def g1 (): return
363390def g2 (): return 1
You can’t perform that action at this time.
0 commit comments