Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a91f255

Browse files
authored
gh-96455: update example in exception_handling_notes.txt to the 3.11RC bytecode (GH-96456)
1 parent 894cafd commit a91f255

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

Objects/exception_handling_notes.txt

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,36 @@ SETUP_FINALLY and POP_BLOCK.
4343
In 3.11, the SETUP_FINALLY and POP_BLOCK are eliminated, replaced with
4444
a table to determine where to jump to when an exception is raised.
4545

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
6467
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
6770

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.)
6972

7073
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.
7376

7477

7578
Unwinding
@@ -84,9 +87,9 @@ This information is stored in the exception table, described below.
8487
If there is no relevant entry, the exception bubbles up to the caller.
8588

8689
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.
8891
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.
9093
4. jump to the target offset and resume execution.
9194

9295

0 commit comments

Comments
 (0)