summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-03-26 14:42:17 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-03-26 17:32:02 +0200
commitc403076ef8c534836a441374ef0366027946de50 (patch)
tree6c55753ab7863e8cec255696035192aadb2dfd1f /py
parent38f0c607b0626ecee9cb2e4aefb25c3756232dab (diff)
downloadmicropython-c403076ef8c534836a441374ef0366027946de50.tar.gz
micropython-c403076ef8c534836a441374ef0366027946de50.zip
vm: Implement raise statement w/o args (reraising last exception).
Diffstat (limited to 'py')
-rw-r--r--py/vm.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/py/vm.c b/py/vm.c
index 22243c403e..98d1250720 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -604,8 +604,14 @@ unwind_return:
case MP_BC_RAISE_VARARGS:
unum = *ip++;
- assert(unum == 1);
- obj1 = POP();
+ assert(unum <= 1);
+ if (unum == 0) {
+ // This assumes that nlr.ret_val holds last raised
+ // exception and is not overwritten since then.
+ obj1 = nlr.ret_val;
+ } else {
+ obj1 = POP();
+ }
nlr_jump(rt_make_raise_obj(obj1));
case MP_BC_YIELD_VALUE: