@@ -1879,7 +1879,7 @@ def test_jump_out_of_block_backwards(output):
1879
1879
output .append (6 )
1880
1880
output .append (7 )
1881
1881
1882
- @async_jump_test (4 , 5 , [3 ], ( ValueError , 'into' ) )
1882
+ @async_jump_test (4 , 5 , [3 , 5 ] )
1883
1883
async def test_jump_out_of_async_for_block_forwards (output ):
1884
1884
for i in [1 ]:
1885
1885
async for i in asynciter ([1 , 2 ]):
@@ -1921,7 +1921,7 @@ def test_jump_in_nested_finally(output):
1921
1921
output .append (8 )
1922
1922
output .append (9 )
1923
1923
1924
- @jump_test (6 , 7 , [2 ], (ValueError , 'within ' ))
1924
+ @jump_test (6 , 7 , [2 , 7 ], (ZeroDivisionError , '' ))
1925
1925
def test_jump_in_nested_finally_2 (output ):
1926
1926
try :
1927
1927
output .append (2 )
@@ -1932,7 +1932,7 @@ def test_jump_in_nested_finally_2(output):
1932
1932
output .append (7 )
1933
1933
output .append (8 )
1934
1934
1935
- @jump_test (6 , 11 , [2 ], (ValueError , 'within ' ))
1935
+ @jump_test (6 , 11 , [2 , 11 ], (ZeroDivisionError , '' ))
1936
1936
def test_jump_in_nested_finally_3 (output ):
1937
1937
try :
1938
1938
output .append (2 )
@@ -2043,8 +2043,8 @@ def test_jump_backwards_out_of_try_except_block(output):
2043
2043
output .append (5 )
2044
2044
raise
2045
2045
2046
- @jump_test (5 , 7 , [4 ], ( ValueError , 'within' ) )
2047
- def test_no_jump_between_except_blocks (output ):
2046
+ @jump_test (5 , 7 , [4 , 7 , 8 ] )
2047
+ def test_jump_between_except_blocks (output ):
2048
2048
try :
2049
2049
1 / 0
2050
2050
except ZeroDivisionError :
@@ -2054,8 +2054,19 @@ def test_no_jump_between_except_blocks(output):
2054
2054
output .append (7 )
2055
2055
output .append (8 )
2056
2056
2057
- @jump_test (5 , 6 , [4 ], (ValueError , 'within' ))
2058
- def test_no_jump_within_except_block (output ):
2057
+ @jump_test (5 , 7 , [4 , 7 , 8 ])
2058
+ def test_jump_from_except_to_finally (output ):
2059
+ try :
2060
+ 1 / 0
2061
+ except ZeroDivisionError :
2062
+ output .append (4 )
2063
+ output .append (5 )
2064
+ finally :
2065
+ output .append (7 )
2066
+ output .append (8 )
2067
+
2068
+ @jump_test (5 , 6 , [4 , 6 , 7 ])
2069
+ def test_jump_within_except_block (output ):
2059
2070
try :
2060
2071
1 / 0
2061
2072
except :
@@ -2290,7 +2301,7 @@ def test_no_jump_backwards_into_for_block(output):
2290
2301
output .append (2 )
2291
2302
output .append (3 )
2292
2303
2293
- @async_jump_test (3 , 2 , [2 , 2 ], (ValueError , 'within' ))
2304
+ @async_jump_test (3 , 2 , [2 , 2 ], (ValueError , "can't jump into the body of a for loop" ))
2294
2305
async def test_no_jump_backwards_into_async_for_block (output ):
2295
2306
async for i in asynciter ([1 , 2 ]):
2296
2307
output .append (2 )
@@ -2355,8 +2366,8 @@ def test_jump_backwards_into_try_except_block(output):
2355
2366
output .append (6 )
2356
2367
2357
2368
# 'except' with a variable creates an implicit finally block
2358
- @jump_test (5 , 7 , [4 ], ( ValueError , 'within' ) )
2359
- def test_no_jump_between_except_blocks_2 (output ):
2369
+ @jump_test (5 , 7 , [4 , 7 , 8 ] )
2370
+ def test_jump_between_except_blocks_2 (output ):
2360
2371
try :
2361
2372
1 / 0
2362
2373
except ZeroDivisionError :
@@ -2392,23 +2403,23 @@ def test_jump_out_of_finally_block(output):
2392
2403
finally :
2393
2404
output .append (5 )
2394
2405
2395
- @jump_test (1 , 5 , [], (ValueError , "into an exception" ))
2406
+ @jump_test (1 , 5 , [], (ValueError , "can't jump into an 'except' block as there's no exception" ))
2396
2407
def test_no_jump_into_bare_except_block (output ):
2397
2408
output .append (1 )
2398
2409
try :
2399
2410
output .append (3 )
2400
2411
except :
2401
2412
output .append (5 )
2402
2413
2403
- @jump_test (1 , 5 , [], (ValueError , "into an exception" ))
2414
+ @jump_test (1 , 5 , [], (ValueError , "can't jump into an 'except' block as there's no exception" ))
2404
2415
def test_no_jump_into_qualified_except_block (output ):
2405
2416
output .append (1 )
2406
2417
try :
2407
2418
output .append (3 )
2408
2419
except Exception :
2409
2420
output .append (5 )
2410
2421
2411
- @jump_test (3 , 6 , [2 , 5 , 6 ], (ValueError , "into an exception" ))
2422
+ @jump_test (3 , 6 , [2 , 5 , 6 ], (ValueError , "can't jump into an 'except' block as there's no exception" ))
2412
2423
def test_no_jump_into_bare_except_block_from_try_block (output ):
2413
2424
try :
2414
2425
output .append (2 )
@@ -2419,7 +2430,7 @@ def test_no_jump_into_bare_except_block_from_try_block(output):
2419
2430
raise
2420
2431
output .append (8 )
2421
2432
2422
- @jump_test (3 , 6 , [2 ], (ValueError , "into an exception" ))
2433
+ @jump_test (3 , 6 , [2 ], (ValueError , "can't jump into an 'except' block as there's no exception" ))
2423
2434
def test_no_jump_into_qualified_except_block_from_try_block (output ):
2424
2435
try :
2425
2436
output .append (2 )
@@ -2430,8 +2441,8 @@ def test_no_jump_into_qualified_except_block_from_try_block(output):
2430
2441
raise
2431
2442
output .append (8 )
2432
2443
2433
- @jump_test (7 , 1 , [1 , 3 , 6 ], ( ValueError , "within" ) )
2434
- def test_no_jump_out_of_bare_except_block (output ):
2444
+ @jump_test (7 , 1 , [1 , 3 , 6 , 1 , 3 , 6 , 7 ] )
2445
+ def test_jump_out_of_bare_except_block (output ):
2435
2446
output .append (1 )
2436
2447
try :
2437
2448
output .append (3 )
@@ -2440,8 +2451,8 @@ def test_no_jump_out_of_bare_except_block(output):
2440
2451
output .append (6 )
2441
2452
output .append (7 )
2442
2453
2443
- @jump_test (7 , 1 , [1 , 3 , 6 ], ( ValueError , "within" ) )
2444
- def test_no_jump_out_of_qualified_except_block (output ):
2454
+ @jump_test (7 , 1 , [1 , 3 , 6 , 1 , 3 , 6 , 7 ] )
2455
+ def test_jump_out_of_qualified_except_block (output ):
2445
2456
output .append (1 )
2446
2457
try :
2447
2458
output .append (3 )
0 commit comments