Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uPython-mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TASTE
uPython-mirror
Commits
d7592a1c
PL1
Commit
d7592a1c
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Fix reraise logic.
parent
010043ca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/vm.c
+12
-6
12 additions, 6 deletions
py/vm.c
with
12 additions
and
6 deletions
py/vm.c
+
12
−
6
View file @
d7592a1c
...
...
@@ -51,12 +51,11 @@ typedef enum {
exc_sp->opcode = op; \
exc_sp->handler = ip + unum; \
exc_sp->val_sp = MP_TAGPTR_MAKE(sp, currently_in_except_block); \
exc_sp->prev_exc =
nlr.ret_val
; \
exc_sp->prev_exc =
MP_OBJ_NULL
; \
currently_in_except_block = 0;
/* in a try block now */
#define POP_EXC_BLOCK() \
currently_in_except_block = MP_TAGPTR_TAG(exc_sp->val_sp);
/* restore previous state */
\
if (currently_in_except_block) { nlr.ret_val = exc_sp->prev_exc; } \
exc_sp--;
/* pop back to previous exception handler */
mp_vm_return_kind_t
mp_execute_byte_code
(
const
byte
*
code
,
const
mp_obj_t
*
args
,
uint
n_args
,
const
mp_obj_t
*
args2
,
uint
n_args2
,
mp_obj_t
*
ret
)
{
...
...
@@ -701,12 +700,17 @@ unwind_return:
unum
=
*
ip
++
;
assert
(
unum
<=
1
);
if
(
unum
==
0
)
{
if
(
!
currently_in_except_block
)
{
// search for the inner-most previous exception, to reraise it
obj1
=
MP_OBJ_NULL
;
for
(
mp_exc_stack
*
e
=
exc_sp
;
e
>=
exc_stack
;
e
--
)
{
if
(
e
->
prev_exc
!=
MP_OBJ_NULL
)
{
obj1
=
e
->
prev_exc
;
break
;
}
}
if
(
obj1
==
MP_OBJ_NULL
)
{
nlr_jump
(
mp_obj_new_exception_msg
(
&
mp_type_RuntimeError
,
"No active exception to reraise"
));
}
// This assumes that nlr.ret_val holds last raised
// exception and is not overwritten since then.
obj1
=
nlr
.
ret_val
;
}
else
{
obj1
=
POP
();
}
...
...
@@ -844,6 +848,8 @@ yield:
// catch exception and pass to byte code
sp
=
MP_TAGPTR_PTR
(
exc_sp
->
val_sp
);
ip
=
exc_sp
->
handler
;
// save this exception in the stack so it can be used in a reraise, if needed
exc_sp
->
prev_exc
=
nlr
.
ret_val
;
// push(traceback, exc-val, exc-type)
PUSH
(
mp_const_none
);
PUSH
(
nlr
.
ret_val
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment