1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# When continuing from nested except handlers, ALL exception states must be cleared.
# After the loop completes its iterations, execution should continue normally.
# Test 1: continue from depth 2 should process all iterations
def test_continue():
results = []
for i in range(3):
try:
raise ValueError('outer')
except:
try:
raise TypeError('inner')
except:
results.append(i)
continue # Should clear BOTH exceptions
return results
assert test_continue() == [0, 1, 2]
# Test 2: continue from depth 3 should also work
def test_continue_depth3():
results = []
for i in range(2):
try:
raise ValueError('level1')
except:
try:
raise TypeError('level2')
except:
try:
raise RuntimeError('level3')
except:
results.append(i)
continue # Should clear ALL THREE exceptions
return results
assert test_continue_depth3() == [0, 1]
# Test 3: continue runs else clause since loop completes normally
def test_continue_with_else():
results = []
for i in range(2):
try:
raise ValueError('outer')
except:
try:
raise TypeError('inner')
except:
results.append(i)
continue
else:
results.append('else')
return results
assert test_continue_with_else() == [0, 1, 'else']