py: Reraising exception possible only in except block.

pull/390/head
Paul Sokolovsky 2014-03-29 19:44:15 +02:00
rodzic f4417a1f95
commit d109676ec0
2 zmienionych plików z 11 dodań i 1 usunięć

Wyświetl plik

@ -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;

Wyświetl plik

@ -1,4 +1,4 @@
# Re-reraising 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")