classification
Title: Simplify bytecodes for try-finally, try-except and with blocks.
Type: Stage: patch review
Components: Interpreter Core Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Mark.Shannon, gregory.p.smith, ncoghlan, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-04-29 18:28 by Mark.Shannon, last changed 2018-07-08 19:44 by gregory.p.smith.

Pull Requests
URL Status Linked Edit
PR 6641 open Mark.Shannon, 2018-04-29 18:36
Messages (1)
msg315905 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2018-04-29 18:28
The six complex bytecodes currently used for implementing 'with' and 'try' statements can be replaced with just two simpler bytecodes.
The six bytecodes are WITH_CLEANUP_START, WITH_CLEANUP_FINISH,
BEGIN_FINALLY, END_FINALLY, CALL_FINALLY and POP_FINALLY.
They can be replaced with RERAISE and WITH_EXCEPT_FINISH.

See https://bugs.python.org/issue32949 for more details of the new bytecodes and how they are used in the 'with' statement.

The try-finally statement can be implemented broadly as 
   SETUP_FINALLY except
   try-body
   POP_BLOCK
   finally-body
   JUMP exit
except:
   finally-body
exit:
History
Date User Action Args
2018-07-08 19:44:06gregory.p.smithsetnosy: + gregory.p.smith, ncoghlan, serhiy.storchaka
2018-04-29 18:36:03Mark.Shannonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request6337
2018-04-29 18:31:10Mark.Shannonsetmessages: - msg315906
2018-04-29 18:30:39Mark.Shannonsetmessages: + msg315906
2018-04-29 18:28:42Mark.Shannoncreate