@@ -43,33 +43,36 @@ SETUP_FINALLY and POP_BLOCK.
43
43
In 3.11, the SETUP_FINALLY and POP_BLOCK are eliminated, replaced with
44
44
a table to determine where to jump to when an exception is raised.
45
45
46
- 2 0 NOP
47
-
48
- 3 2 LOAD_GLOBAL 0 (g)
49
- 4 LOAD_CONST 1 (0)
50
- 6 CALL_NO_KW 1
51
- 8 POP_TOP
52
- 10 LOAD_CONST 0 (None)
53
- 12 RETURN_VALUE
54
- >> 14 PUSH_EXC_INFO
55
-
56
- 4 16 POP_TOP
57
- 18 POP_TOP
58
- 20 POP_TOP
59
-
60
- 5 22 POP_EXCEPT
61
- 24 LOAD_CONST 2 ('fail')
62
- 26 RETURN_VALUE
63
- >> 28 POP_EXCEPT_AND_RERAISE
46
+ 1 0 RESUME 0
47
+
48
+ 2 2 NOP
49
+
50
+ 3 4 LOAD_GLOBAL 1 (NULL + g)
51
+ 16 LOAD_CONST 1 (0)
52
+ 18 PRECALL 1
53
+ 22 CALL 1
54
+ 32 POP_TOP
55
+ 34 LOAD_CONST 0 (None)
56
+ 36 RETURN_VALUE
57
+ >> 38 PUSH_EXC_INFO
58
+
59
+ 4 40 POP_TOP
60
+
61
+ 5 42 POP_EXCEPT
62
+ 44 LOAD_CONST 2 ('fail')
63
+ 46 RETURN_VALUE
64
+ >> 48 COPY 3
65
+ 50 POP_EXCEPT
66
+ 52 RERAISE 1
64
67
ExceptionTable:
65
- 2 to 8 -> 14 [0]
66
- 14 to 20 -> 28 [3 ] lasti
68
+ 4 to 32 -> 38 [0]
69
+ 38 to 40 -> 48 [1 ] lasti
67
70
68
- (Note this code is from an early 3.11 alpha, the NOP may well have be removed before release).
71
+ (Note this code is from 3.11, later versions may have slightly different bytecode.)
69
72
70
73
If an instruction raises an exception then its offset is used to find the target to jump to.
71
- For example, the CALL_NO_KW at offset 6 , falls into the range 2 to 8 .
72
- So, if g() raises an exception, then control jumps to offset 14 .
74
+ For example, the CALL at offset 22 , falls into the range 4 to 32 .
75
+ So, if g() raises an exception, then control jumps to offset 38 .
73
76
74
77
75
78
Unwinding
@@ -84,9 +87,9 @@ This information is stored in the exception table, described below.
84
87
If there is no relevant entry, the exception bubbles up to the caller.
85
88
86
89
If there is an entry, then:
87
- 1. pop values from the stack until it matches the stack depth for the handler,
90
+ 1. pop values from the stack until it matches the stack depth for the handler.
88
91
2. if 'lasti' is true, then push the offset that the exception was raised at.
89
- 3. push the exception to the stack as three values: traceback, value, type,
92
+ 3. push the exception to the stack.
90
93
4. jump to the target offset and resume execution.
91
94
92
95
0 commit comments