@@ -1201,8 +1201,16 @@ def test_no_jump_between_except_blocks_2(output):
12011201 output .append (7 )
12021202 output .append (8 )
12031203
1204- @jump_test (3 , 6 , [ 2 , 5 , 6 ], (ValueError , 'finally' ))
1204+ @jump_test (1 , 5 , [ ], (ValueError , "into a 'finally'" ))
12051205 def test_no_jump_into_finally_block (output ):
1206+ output .append (1 )
1207+ try :
1208+ output .append (3 )
1209+ finally :
1210+ output .append (5 )
1211+
1212+ @jump_test (3 , 6 , [2 , 5 , 6 ], (ValueError , "into a 'finally'" ))
1213+ def test_no_jump_into_finally_block_from_try_block (output ):
12061214 try :
12071215 output .append (2 )
12081216 output .append (3 )
@@ -1211,21 +1219,71 @@ def test_no_jump_into_finally_block(output):
12111219 output .append (6 )
12121220 output .append (7 )
12131221
1214- @jump_test (1 , 5 , [], (ValueError , 'finally' ))
1215- def test_no_jump_into_finally_block_2 (output ):
1222+ @jump_test (5 , 1 , [1 , 3 ], (ValueError , "out of a 'finally'" ))
1223+ def test_no_jump_out_of_finally_block (output ):
12161224 output .append (1 )
12171225 try :
12181226 output .append (3 )
12191227 finally :
12201228 output .append (5 )
12211229
1222- @jump_test (5 , 1 , [ 1 , 3 ], (ValueError , 'finally' ))
1223- def test_no_jump_out_of_finally_block (output ):
1230+ @jump_test (1 , 5 , [ ], (ValueError , "into an 'except'" ))
1231+ def test_no_jump_into_bare_except_block (output ):
12241232 output .append (1 )
12251233 try :
12261234 output .append (3 )
1227- finally :
1235+ except :
1236+ output .append (5 )
1237+
1238+ @jump_test (1 , 5 , [], (ValueError , "into an 'except'" ))
1239+ def test_no_jump_into_qualified_except_block (output ):
1240+ output .append (1 )
1241+ try :
1242+ output .append (3 )
1243+ except Exception :
1244+ output .append (5 )
1245+
1246+ @jump_test (3 , 6 , [2 , 5 , 6 ], (ValueError , "into an 'except'" ))
1247+ def test_no_jump_into_bare_except_block_from_try_block (output ):
1248+ try :
1249+ output .append (2 )
1250+ output .append (3 )
1251+ except : # executed if the jump is failed
12281252 output .append (5 )
1253+ output .append (6 )
1254+ raise
1255+ output .append (8 )
1256+
1257+ @jump_test (3 , 6 , [2 ], (ValueError , "into an 'except'" ))
1258+ def test_no_jump_into_qualified_except_block_from_try_block (output ):
1259+ try :
1260+ output .append (2 )
1261+ output .append (3 )
1262+ except ZeroDivisionError :
1263+ output .append (5 )
1264+ output .append (6 )
1265+ raise
1266+ output .append (8 )
1267+
1268+ @jump_test (7 , 1 , [1 , 3 , 6 ], (ValueError , "out of an 'except'" ))
1269+ def test_no_jump_out_of_bare_except_block (output ):
1270+ output .append (1 )
1271+ try :
1272+ output .append (3 )
1273+ 1 / 0
1274+ except :
1275+ output .append (6 )
1276+ output .append (7 )
1277+
1278+ @jump_test (7 , 1 , [1 , 3 , 6 ], (ValueError , "out of an 'except'" ))
1279+ def test_no_jump_out_of_qualified_except_block (output ):
1280+ output .append (1 )
1281+ try :
1282+ output .append (3 )
1283+ 1 / 0
1284+ except Exception :
1285+ output .append (6 )
1286+ output .append (7 )
12291287
12301288 @jump_test (3 , 5 , [1 , 2 , - 2 ], (ValueError , 'into' ))
12311289 def test_no_jump_between_with_blocks (output ):
0 commit comments