vm: Save current active exception on opening new try block.#390
Merged
dpgeorge merged 1 commit intomicropython:masterfrom Mar 30, 2014
Merged
vm: Save current active exception on opening new try block.#390dpgeorge merged 1 commit intomicropython:masterfrom
dpgeorge merged 1 commit intomicropython:masterfrom
Conversation
Required to reraise correct exceptions in except block, regardless if more try blocks with active exceptions happen in the same except block. P.S. This "automagic reraise" appears to be quite wasteful feature of Python - we need to save pending exception just in case it *might* be reraised. Instead, programmer could explcitly capture exception to a variable using "except ... as var", and reraise that. So, consider disabling argless raise support as an optimization.
Contributor
Author
|
This resolves (in one way) issues discussed in #379 (comment) |
Member
|
Now that the previous exception is stored in this stack structure, would it not be possible to use that entry for the raise-with-no-args byte code? Ie instead of accessing nlr.ret_val and hoping it's the last exception raised, use exc_sp->exc_prev (or maybe exc_sp[-1] or something like that)? |
dpgeorge
added a commit
that referenced
this pull request
Mar 30, 2014
vm: Save current active exception on opening new try block.
Contributor
Author
|
Well, no hoping any more - 0c904df just restores it ;-). Using value directly on exc_stack probably won't work, because it's previous value and it might not exist. Probably ;-). |
Member
|
See my recent commits: it can be done, and it's better to be done :) |
Contributor
Author
Cool, seems to have fixed #392 too ;-). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Required to reraise correct exceptions in except block, regardless if more
try blocks with active exceptions happen in the same except block.
P.S. This "automagic reraise" appears to be quite wasteful feature of Python
Instead, programmer could explcitly capture exception to a variable using
"except ... as var", and reraise that. So, consider disabling argless raise
support as an optimization.