Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
d109676e
Commit
d109676e
authored
Mar 29, 2014
by
Paul Sokolovsky
Browse files
py: Reraising exception possible only in except block.
parent
f4417a1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/vm.c
View file @
d109676e
...
...
@@ -697,6 +697,9 @@ unwind_return:
unum
=
*
ip
++
;
assert
(
unum
<=
1
);
if
(
unum
==
0
)
{
if
(
!
currently_in_except_block
)
{
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
;
...
...
tests/basics/try-reraise.py
View file @
d109676e
# Re
-re
raising last exception with raise w/o args
# Reraising last exception with raise w/o args
def
f
():
try
:
...
...
@@ -10,3 +10,10 @@ try:
f
()
except
ValueError
as
e
:
print
(
repr
(
e
))
# Can reraise only in except block
try
:
raise
except
RuntimeError
:
print
(
"RuntimeError"
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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