Skip to content

vm: Save current active exception on opening new try block.#390

Merged
dpgeorge merged 1 commit intomicropython:masterfrom
pfalcon:reraise-recursive
Mar 30, 2014
Merged

vm: Save current active exception on opening new try block.#390
dpgeorge merged 1 commit intomicropython:masterfrom
pfalcon:reraise-recursive

Conversation

@pfalcon
Copy link
Copy Markdown
Contributor

@pfalcon pfalcon commented Mar 29, 2014

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.

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.
@pfalcon
Copy link
Copy Markdown
Contributor Author

pfalcon commented Mar 29, 2014

This resolves (in one way) issues discussed in #379 (comment)

@dpgeorge
Copy link
Copy Markdown
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.
@dpgeorge dpgeorge merged commit f8ff700 into micropython:master Mar 30, 2014
@pfalcon
Copy link
Copy Markdown
Contributor Author

pfalcon commented Mar 30, 2014

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 ;-).

@dpgeorge
Copy link
Copy Markdown
Member

See my recent commits: it can be done, and it's better to be done :)

@pfalcon
Copy link
Copy Markdown
Contributor Author

pfalcon commented Mar 30, 2014

it can be done, and it's better to be done :)

Cool, seems to have fixed #392 too ;-).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants