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, cheryl.sabella, gregory.p.smith, ncoghlan, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-04-29 18:28 by Mark.Shannon, last changed 2019-04-09 23:32 by cheryl.sabella.

Pull Requests
URL Status Linked Edit
PR 6641 open Mark.Shannon, 2018-04-29 18:36
Messages (2)
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:
msg339817 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-04-09 23:32
What would be the best way to resolve the discussion between this and issue 32949?  Would it be good to try to get one of them into 3.8?
History
Date User Action Args
2019-04-09 23:32:02cheryl.sabellasetnosy: + cheryl.sabella
messages: + msg339817
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