Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
d7592a1c
Commit
d7592a1c
authored
Mar 30, 2014
by
Damien George
Browse files
py: Fix reraise logic.
parent
010043ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/vm.c
View file @
d7592a1c
...
@@ -51,12 +51,11 @@ typedef enum {
...
@@ -51,12 +51,11 @@ typedef enum {
exc_sp->opcode = op; \
exc_sp->opcode = op; \
exc_sp->handler = ip + unum; \
exc_sp->handler = ip + unum; \
exc_sp->val_sp = MP_TAGPTR_MAKE(sp, currently_in_except_block); \
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 */
currently_in_except_block = 0;
/* in a try block now */
#define POP_EXC_BLOCK() \
#define POP_EXC_BLOCK() \
currently_in_except_block = MP_TAGPTR_TAG(exc_sp->val_sp);
/* restore previous state */
\
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 */
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
)
{
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:
...
@@ -701,12 +700,17 @@ unwind_return:
unum
=
*
ip
++
;
unum
=
*
ip
++
;
assert
(
unum
<=
1
);
assert
(
unum
<=
1
);
if
(
unum
==
0
)
{
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"
));
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
{
}
else
{
obj1
=
POP
();
obj1
=
POP
();
}
}
...
@@ -844,6 +848,8 @@ yield:
...
@@ -844,6 +848,8 @@ yield:
// catch exception and pass to byte code
// catch exception and pass to byte code
sp
=
MP_TAGPTR_PTR
(
exc_sp
->
val_sp
);
sp
=
MP_TAGPTR_PTR
(
exc_sp
->
val_sp
);
ip
=
exc_sp
->
handler
;
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(traceback, exc-val, exc-type)
PUSH
(
mp_const_none
);
PUSH
(
mp_const_none
);
PUSH
(
nlr
.
ret_val
);
PUSH
(
nlr
.
ret_val
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment