@@ -274,32 +274,34 @@ def bug1333982(x=[]):
274
274
--> 6 BINARY_TRUE_DIVIDE
275
275
8 POP_TOP
276
276
10 POP_BLOCK
277
- 12 JUMP_FORWARD 40 (to 54 )
277
+ 12 JUMP_FORWARD 44 (to 58 )
278
278
279
279
%3d >> 14 DUP_TOP
280
280
16 LOAD_GLOBAL 0 (Exception)
281
281
18 COMPARE_OP 10 (exception match)
282
- 20 POP_JUMP_IF_FALSE 52
282
+ 20 POP_JUMP_IF_FALSE 56
283
283
22 POP_TOP
284
284
24 STORE_FAST 0 (e)
285
285
26 POP_TOP
286
- 28 SETUP_FINALLY 10 (to 40 )
286
+ 28 SETUP_FINALLY 18 (to 48 )
287
287
288
288
%3d 30 LOAD_FAST 0 (e)
289
289
32 LOAD_ATTR 1 (__traceback__)
290
290
34 STORE_FAST 1 (tb)
291
291
36 POP_BLOCK
292
- 38 BEGIN_FINALLY
293
- >> 40 LOAD_CONST 0 (None)
292
+ 38 POP_EXCEPT
293
+ 40 LOAD_CONST 0 (None)
294
294
42 STORE_FAST 0 (e)
295
295
44 DELETE_FAST 0 (e)
296
- 46 END_FINALLY
297
- 48 POP_EXCEPT
298
- 50 JUMP_FORWARD 2 (to 54)
299
- >> 52 END_FINALLY
300
-
301
- %3d >> 54 LOAD_FAST 1 (tb)
302
- 56 RETURN_VALUE
296
+ 46 JUMP_FORWARD 10 (to 58)
297
+ >> 48 LOAD_CONST 0 (None)
298
+ 50 STORE_FAST 0 (e)
299
+ 52 DELETE_FAST 0 (e)
300
+ 54 RERAISE
301
+ >> 56 RERAISE
302
+
303
+ %3d >> 58 LOAD_FAST 1 (tb)
304
+ 60 RETURN_VALUE
303
305
""" % (TRACEBACK_CODE .co_firstlineno + 1 ,
304
306
TRACEBACK_CODE .co_firstlineno + 2 ,
305
307
TRACEBACK_CODE .co_firstlineno + 3 ,
@@ -740,7 +742,7 @@ async def async_def():
740
742
Argument count: 0
741
743
Kw-only arguments: 0
742
744
Number of locals: 2
743
- Stack size: 10
745
+ Stack size: 9
744
746
Flags: OPTIMIZED, NEWLOCALS, NOFREE, COROUTINE
745
747
Constants:
746
748
0: None
@@ -965,7 +967,7 @@ def jumpy():
965
967
Instruction (opname = 'LOAD_CONST' , opcode = 100 , arg = 6 , argval = 'Who let lolcatz into this test suite?' , argrepr = "'Who let lolcatz into this test suite?'" , offset = 96 , starts_line = None , is_jump_target = False ),
966
968
Instruction (opname = 'CALL_FUNCTION' , opcode = 131 , arg = 1 , argval = 1 , argrepr = '' , offset = 98 , starts_line = None , is_jump_target = False ),
967
969
Instruction (opname = 'POP_TOP' , opcode = 1 , arg = None , argval = None , argrepr = '' , offset = 100 , starts_line = None , is_jump_target = False ),
968
- Instruction (opname = 'SETUP_FINALLY' , opcode = 122 , arg = 70 , argval = 174 , argrepr = 'to 174 ' , offset = 102 , starts_line = 20 , is_jump_target = True ),
970
+ Instruction (opname = 'SETUP_FINALLY' , opcode = 122 , arg = 98 , argval = 202 , argrepr = 'to 202 ' , offset = 102 , starts_line = 20 , is_jump_target = True ),
969
971
Instruction (opname = 'SETUP_FINALLY' , opcode = 122 , arg = 12 , argval = 118 , argrepr = 'to 118' , offset = 104 , starts_line = None , is_jump_target = False ),
970
972
Instruction (opname = 'LOAD_CONST' , opcode = 100 , arg = 5 , argval = 1 , argrepr = '1' , offset = 106 , starts_line = 21 , is_jump_target = False ),
971
973
Instruction (opname = 'LOAD_CONST' , opcode = 100 , arg = 7 , argval = 0 , argrepr = '0' , offset = 108 , starts_line = None , is_jump_target = False ),
@@ -985,29 +987,43 @@ def jumpy():
985
987
Instruction (opname = 'CALL_FUNCTION' , opcode = 131 , arg = 1 , argval = 1 , argrepr = '' , offset = 136 , starts_line = None , is_jump_target = False ),
986
988
Instruction (opname = 'POP_TOP' , opcode = 1 , arg = None , argval = None , argrepr = '' , offset = 138 , starts_line = None , is_jump_target = False ),
987
989
Instruction (opname = 'POP_EXCEPT' , opcode = 89 , arg = None , argval = None , argrepr = '' , offset = 140 , starts_line = None , is_jump_target = False ),
988
- Instruction (opname = 'JUMP_FORWARD' , opcode = 110 , arg = 26 , argval = 170 , argrepr = 'to 170 ' , offset = 142 , starts_line = None , is_jump_target = False ),
989
- Instruction (opname = 'END_FINALLY ' , opcode = 88 , arg = None , argval = None , argrepr = '' , offset = 144 , starts_line = None , is_jump_target = True ),
990
+ Instruction (opname = 'JUMP_FORWARD' , opcode = 110 , arg = 46 , argval = 190 , argrepr = 'to 190 ' , offset = 142 , starts_line = None , is_jump_target = False ),
991
+ Instruction (opname = 'RERAISE ' , opcode = 48 , arg = None , argval = None , argrepr = '' , offset = 144 , starts_line = None , is_jump_target = True ),
990
992
Instruction (opname = 'LOAD_FAST' , opcode = 124 , arg = 0 , argval = 'i' , argrepr = 'i' , offset = 146 , starts_line = 25 , is_jump_target = True ),
991
- Instruction (opname = 'SETUP_WITH' , opcode = 143 , arg = 14 , argval = 164 , argrepr = 'to 164 ' , offset = 148 , starts_line = None , is_jump_target = False ),
993
+ Instruction (opname = 'SETUP_WITH' , opcode = 143 , arg = 24 , argval = 174 , argrepr = 'to 174 ' , offset = 148 , starts_line = None , is_jump_target = False ),
992
994
Instruction (opname = 'STORE_FAST' , opcode = 125 , arg = 1 , argval = 'dodgy' , argrepr = 'dodgy' , offset = 150 , starts_line = None , is_jump_target = False ),
993
995
Instruction (opname = 'LOAD_GLOBAL' , opcode = 116 , arg = 1 , argval = 'print' , argrepr = 'print' , offset = 152 , starts_line = 26 , is_jump_target = False ),
994
996
Instruction (opname = 'LOAD_CONST' , opcode = 100 , arg = 9 , argval = 'Never reach this' , argrepr = "'Never reach this'" , offset = 154 , starts_line = None , is_jump_target = False ),
995
997
Instruction (opname = 'CALL_FUNCTION' , opcode = 131 , arg = 1 , argval = 1 , argrepr = '' , offset = 156 , starts_line = None , is_jump_target = False ),
996
998
Instruction (opname = 'POP_TOP' , opcode = 1 , arg = None , argval = None , argrepr = '' , offset = 158 , starts_line = None , is_jump_target = False ),
997
999
Instruction (opname = 'POP_BLOCK' , opcode = 87 , arg = None , argval = None , argrepr = '' , offset = 160 , starts_line = None , is_jump_target = False ),
998
- Instruction (opname = 'BEGIN_FINALLY' , opcode = 53 , arg = None , argval = None , argrepr = '' , offset = 162 , starts_line = None , is_jump_target = False ),
999
- Instruction (opname = 'WITH_CLEANUP_START' , opcode = 81 , arg = None , argval = None , argrepr = '' , offset = 164 , starts_line = None , is_jump_target = True ),
1000
- Instruction (opname = 'WITH_CLEANUP_FINISH' , opcode = 82 , arg = None , argval = None , argrepr = '' , offset = 166 , starts_line = None , is_jump_target = False ),
1001
- Instruction (opname = 'END_FINALLY' , opcode = 88 , arg = None , argval = None , argrepr = '' , offset = 168 , starts_line = None , is_jump_target = False ),
1002
- Instruction (opname = 'POP_BLOCK' , opcode = 87 , arg = None , argval = None , argrepr = '' , offset = 170 , starts_line = None , is_jump_target = True ),
1003
- Instruction (opname = 'BEGIN_FINALLY' , opcode = 53 , arg = None , argval = None , argrepr = '' , offset = 172 , starts_line = None , is_jump_target = False ),
1004
- Instruction (opname = 'LOAD_GLOBAL' , opcode = 116 , arg = 1 , argval = 'print' , argrepr = 'print' , offset = 174 , starts_line = 28 , is_jump_target = True ),
1005
- Instruction (opname = 'LOAD_CONST' , opcode = 100 , arg = 10 , argval = "OK, now we're done" , argrepr = '"OK, now we\' re done"' , offset = 176 , starts_line = None , is_jump_target = False ),
1006
- Instruction (opname = 'CALL_FUNCTION' , opcode = 131 , arg = 1 , argval = 1 , argrepr = '' , offset = 178 , starts_line = None , is_jump_target = False ),
1007
- Instruction (opname = 'POP_TOP' , opcode = 1 , arg = None , argval = None , argrepr = '' , offset = 180 , starts_line = None , is_jump_target = False ),
1008
- Instruction (opname = 'END_FINALLY' , opcode = 88 , arg = None , argval = None , argrepr = '' , offset = 182 , starts_line = None , is_jump_target = False ),
1009
- Instruction (opname = 'LOAD_CONST' , opcode = 100 , arg = 0 , argval = None , argrepr = 'None' , offset = 184 , starts_line = None , is_jump_target = False ),
1010
- Instruction (opname = 'RETURN_VALUE' , opcode = 83 , arg = None , argval = None , argrepr = '' , offset = 186 , starts_line = None , is_jump_target = False ),
1000
+ Instruction (opname = 'LOAD_CONST' , opcode = 100 , arg = 0 , argval = None , argrepr = 'None' , offset = 162 , starts_line = None , is_jump_target = False ),
1001
+ Instruction (opname = 'DUP_TOP' , opcode = 4 , arg = None , argval = None , argrepr = '' , offset = 164 , starts_line = None , is_jump_target = False ),
1002
+ Instruction (opname = 'DUP_TOP' , opcode = 4 , arg = None , argval = None , argrepr = '' , offset = 166 , starts_line = None , is_jump_target = False ),
1003
+ Instruction (opname = 'CALL_FUNCTION' , opcode = 131 , arg = 3 , argval = 3 , argrepr = '' , offset = 168 , starts_line = None , is_jump_target = False ),
1004
+ Instruction (opname = 'POP_TOP' , opcode = 1 , arg = None , argval = None , argrepr = '' , offset = 170 , starts_line = None , is_jump_target = False ),
1005
+ Instruction (opname = 'JUMP_FORWARD' , opcode = 110 , arg = 16 , argval = 190 , argrepr = 'to 190' , offset = 172 , starts_line = None , is_jump_target = False ),
1006
+ Instruction (opname = 'WITH_EXCEPT_START' , opcode = 49 , arg = None , argval = None , argrepr = '' , offset = 174 , starts_line = None , is_jump_target = True ),
1007
+ Instruction (opname = 'POP_JUMP_IF_TRUE' , opcode = 115 , arg = 180 , argval = 180 , argrepr = '' , offset = 176 , starts_line = None , is_jump_target = False ),
1008
+ Instruction (opname = 'RERAISE' , opcode = 48 , arg = None , argval = None , argrepr = '' , offset = 178 , starts_line = None , is_jump_target = False ),
1009
+ Instruction (opname = 'POP_TOP' , opcode = 1 , arg = None , argval = None , argrepr = '' , offset = 180 , starts_line = None , is_jump_target = True ),
1010
+ Instruction (opname = 'POP_TOP' , opcode = 1 , arg = None , argval = None , argrepr = '' , offset = 182 , starts_line = None , is_jump_target = False ),
1011
+ Instruction (opname = 'POP_TOP' , opcode = 1 , arg = None , argval = None , argrepr = '' , offset = 184 , starts_line = None , is_jump_target = False ),
1012
+ Instruction (opname = 'POP_EXCEPT' , opcode = 89 , arg = None , argval = None , argrepr = '' , offset = 186 , starts_line = None , is_jump_target = False ),
1013
+ Instruction (opname = 'POP_TOP' , opcode = 1 , arg = None , argval = None , argrepr = '' , offset = 188 , starts_line = None , is_jump_target = False ),
1014
+ Instruction (opname = 'POP_BLOCK' , opcode = 87 , arg = None , argval = None , argrepr = '' , offset = 190 , starts_line = None , is_jump_target = True ),
1015
+ Instruction (opname = 'LOAD_GLOBAL' , opcode = 116 , arg = 1 , argval = 'print' , argrepr = 'print' , offset = 192 , starts_line = 28 , is_jump_target = False ),
1016
+ Instruction (opname = 'LOAD_CONST' , opcode = 100 , arg = 10 , argval = "OK, now we're done" , argrepr = '"OK, now we\' re done"' , offset = 194 , starts_line = None , is_jump_target = False ),
1017
+ Instruction (opname = 'CALL_FUNCTION' , opcode = 131 , arg = 1 , argval = 1 , argrepr = '' , offset = 196 , starts_line = None , is_jump_target = False ),
1018
+ Instruction (opname = 'POP_TOP' , opcode = 1 , arg = None , argval = None , argrepr = '' , offset = 198 , starts_line = None , is_jump_target = False ),
1019
+ Instruction (opname = 'JUMP_FORWARD' , opcode = 110 , arg = 10 , argval = 212 , argrepr = 'to 212' , offset = 200 , starts_line = None , is_jump_target = False ),
1020
+ Instruction (opname = 'LOAD_GLOBAL' , opcode = 116 , arg = 1 , argval = 'print' , argrepr = 'print' , offset = 202 , starts_line = None , is_jump_target = True ),
1021
+ Instruction (opname = 'LOAD_CONST' , opcode = 100 , arg = 10 , argval = "OK, now we're done" , argrepr = '"OK, now we\' re done"' , offset = 204 , starts_line = None , is_jump_target = False ),
1022
+ Instruction (opname = 'CALL_FUNCTION' , opcode = 131 , arg = 1 , argval = 1 , argrepr = '' , offset = 206 , starts_line = None , is_jump_target = False ),
1023
+ Instruction (opname = 'POP_TOP' , opcode = 1 , arg = None , argval = None , argrepr = '' , offset = 208 , starts_line = None , is_jump_target = False ),
1024
+ Instruction (opname = 'RERAISE' , opcode = 48 , arg = None , argval = None , argrepr = '' , offset = 210 , starts_line = None , is_jump_target = False ),
1025
+ Instruction (opname = 'LOAD_CONST' , opcode = 100 , arg = 0 , argval = None , argrepr = 'None' , offset = 212 , starts_line = None , is_jump_target = True ),
1026
+ Instruction (opname = 'RETURN_VALUE' , opcode = 83 , arg = None , argval = None , argrepr = '' , offset = 214 , starts_line = None , is_jump_target = False )
1011
1027
]
1012
1028
1013
1029
# One last piece of inspect fodder to check the default line number handling
@@ -1020,6 +1036,10 @@ def simple(): pass
1020
1036
1021
1037
class InstructionTests (BytecodeTestCase ):
1022
1038
1039
+ def __init__ (self , * args ):
1040
+ super ().__init__ (* args )
1041
+ self .maxDiff = None
1042
+
1023
1043
def test_default_first_line (self ):
1024
1044
actual = dis .get_instructions (simple )
1025
1045
self .assertEqual (list (actual ), expected_opinfo_simple )
@@ -1051,6 +1071,7 @@ def test_jumpy(self):
1051
1071
# get_instructions has its own tests above, so can rely on it to validate
1052
1072
# the object oriented API
1053
1073
class BytecodeTests (unittest .TestCase ):
1074
+
1054
1075
def test_instantiation (self ):
1055
1076
# Test with function, method, code string and code object
1056
1077
for obj in [_f , _C (1 ).__init__ , "a=1" , _f .__code__ ]:
0 commit comments