msg315905 - (view) |
Author: Mark Shannon (Mark.Shannon) *  |
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) *  |
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? |
|
|
msg357147 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2019-11-21 10:06 |
Mark merged his PR 6641 but forgot to mention bpo-33387: commit fee552669f21ca294f57fe0df826945edc779090 Author: Mark Shannon <mark@hotpy.org> Date: Thu Nov 21 09:11:43 2019 +0000 Produce cleaner bytecode for 'with' and 'async with' by generating separate code for normal and exceptional paths. (#6641) Remove BEGIN_FINALLY, END_FINALLY, CALL_FINALLY and POP_FINALLY bytecodes. Implement finally blocks by code duplication. Reimplement frame.lineno setter using line numbers rather than bytecode offsets. |
|
|
msg357148 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2019-11-21 10:07 |
The new doc seems to use Python version 3.8, but the change was merged into master which is the future Python 3.9, no? .. opcode:: RERAISE Re-raises the exception currently on top of the stack. .. versionadded:: 3.8 |
|
|
msg357155 - (view) |
Author: Mark Shannon (Mark.Shannon) *  |
Date: 2019-11-21 10:32 |
Thanks for noticing. https://github.com/python/cpython/pull/17318 |
|
|
msg357172 - (view) |
Author: Mark Shannon (Mark.Shannon) *  |
Date: 2019-11-21 14:47 |
New changeset 82f897bf8f72d09f537054d64a94e645ad23d8d6 by Mark Shannon in branch 'master': Correct release version to 3.9 for RERAISE and WITH_EXCEPT_START bytecodes. (#17318) https://github.com/python/cpython/commit/82f897bf8f72d09f537054d64a94e645ad23d8d6 |
|
|
msg357246 - (view) |
Author: Gregory P. Smith (gregory.p.smith) *  |
Date: 2019-11-22 06:35 |
sweet! =) |
|
|
msg357279 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2019-11-22 13:28 |
Can this issue be closed now? |
|
|
msg360393 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2020-01-21 11:47 |
New changeset 629023c05be24fa2f01c914c739aaa5a61a0304c by Victor Stinner in branch 'master': bpo-33387: Fix compiler warning in frame_block_unwind() (GH-18099) https://github.com/python/cpython/commit/629023c05be24fa2f01c914c739aaa5a61a0304c |
|
|
msg378715 - (view) |
Author: Xavier Morel (xmorel) * |
Date: 2020-10-16 14:06 |
The 3.9 changelog mentions WITH_EXCEPT_FINISH but that seems to have ultimately been called WITH_EXCEPT_START, maybe it shoudl be updated also? |
|
|
msg378720 - (view) |
Author: Mark Shannon (Mark.Shannon) *  |
Date: 2020-10-16 16:47 |
Yes, thanks for pointing that out. |
|
|
msg385664 - (view) |
Author: Irit Katriel (iritkatriel) *  |
Date: 2021-01-25 21:03 |
I'm reopening this to delete an obsolete comment left behind. |
|
|
msg385679 - (view) |
Author: Irit Katriel (iritkatriel) *  |
Date: 2021-01-25 23:23 |
There's another place that needs to be updated: https://docs.python.org/3/library/dis.html#opcode-SETUP_WITH need to replace WITH_CLEANUP_START by WITH_EXCEPT_START |
|
|
msg385703 - (view) |
Author: Mark Shannon (Mark.Shannon) *  |
Date: 2021-01-26 10:17 |
New changeset dea5bf9d15999bfcc58095b157c0678d45b00bdd by Irit Katriel in branch 'master': bpo-33387: update documentation for exception handling opcode changes (GH-24334) https://github.com/python/cpython/commit/dea5bf9d15999bfcc58095b157c0678d45b00bdd |
|
|