Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cpython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sip
Cpython
Commits
a91f2557
Unverified
Commit
a91f2557
authored
2 years ago
by
Irit Katriel
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
gh-96455: update example in exception_handling_notes.txt to the 3.11RC bytecode (GH-96456)
parent
894cafd9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Objects/exception_handling_notes.txt
+28
-25
28 additions, 25 deletions
Objects/exception_handling_notes.txt
with
28 additions
and
25 deletions
Objects/exception_handling_notes.txt
+
28
−
25
View file @
a91f2557
...
...
@@ -43,33 +43,36 @@ SETUP_FINALLY and POP_BLOCK.
In 3.11, the SETUP_FINALLY and POP_BLOCK are eliminated, replaced with
a table to determine where to jump to when an exception is raised.
2 0 NOP
3 2 LOAD_GLOBAL 0 (g)
4 LOAD_CONST 1 (0)
6 CALL_NO_KW 1
8 POP_TOP
10 LOAD_CONST 0 (None)
12 RETURN_VALUE
>> 14 PUSH_EXC_INFO
4 16 POP_TOP
18 POP_TOP
20 POP_TOP
5 22 POP_EXCEPT
24 LOAD_CONST 2 ('fail')
26 RETURN_VALUE
>> 28 POP_EXCEPT_AND_RERAISE
1 0 RESUME 0
2 2 NOP
3 4 LOAD_GLOBAL 1 (NULL + g)
16 LOAD_CONST 1 (0)
18 PRECALL 1
22 CALL 1
32 POP_TOP
34 LOAD_CONST 0 (None)
36 RETURN_VALUE
>> 38 PUSH_EXC_INFO
4 40 POP_TOP
5 42 POP_EXCEPT
44 LOAD_CONST 2 ('fail')
46 RETURN_VALUE
>> 48 COPY 3
50 POP_EXCEPT
52 RERAISE 1
ExceptionTable:
2
to
8
->
14
[0]
14
to
2
0 ->
2
8 [
3
] lasti
4
to
32
->
38
[0]
38
to
4
0 ->
4
8 [
1
] lasti
(Note this code is from
an early 3.11 alpha, the NOP may well have be removed before release).
(Note this code is from
3.11, later versions may have slightly different bytecode.)
If an instruction raises an exception then its offset is used to find the target to jump to.
For example, the CALL
_NO_KW
at offset
6
, falls into the range
2
to
8
.
So, if g() raises an exception, then control jumps to offset
14
.
For example, the CALL at offset
22
, falls into the range
4
to
32
.
So, if g() raises an exception, then control jumps to offset
38
.
Unwinding
...
...
@@ -84,9 +87,9 @@ This information is stored in the exception table, described below.
If there is no relevant entry, the exception bubbles up to the caller.
If there is an entry, then:
1. pop values from the stack until it matches the stack depth for the handler
,
1. pop values from the stack until it matches the stack depth for the handler
.
2. if 'lasti' is true, then push the offset that the exception was raised at.
3. push the exception to the stack
as three values: traceback, value, type,
3. push the exception to the stack
.
4. jump to the target offset and resume execution.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment