mirror of
https://github.com/python/cpython.git
synced 2025-11-02 19:12:55 +00:00
a better place. Excessively fragile code, but at least it breaks when something in this area changes!
This commit is contained in:
parent
65279d0242
commit
80d373cbd0
2 changed files with 28 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ break_stmt
|
||||||
continue_stmt
|
continue_stmt
|
||||||
continue + try/except ok
|
continue + try/except ok
|
||||||
continue + try/finally ok
|
continue + try/finally ok
|
||||||
|
testing continue and break in try/except in loop
|
||||||
return_stmt
|
return_stmt
|
||||||
raise_stmt
|
raise_stmt
|
||||||
import_stmt
|
import_stmt
|
||||||
|
|
|
||||||
|
|
@ -358,6 +358,33 @@ while not msg:
|
||||||
msg = "continue + try/finally ok"
|
msg = "continue + try/finally ok"
|
||||||
print msg
|
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]
|
print 'return_stmt' # 'return' [testlist]
|
||||||
def g1(): return
|
def g1(): return
|
||||||
def g2(): return 1
|
def g2(): return 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue