From 5388a3c29a5f25aa195c5e4f04aae334a8c08bc4 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 10 Jan 2014 16:09:55 +0200 Subject: [PATCH] Crude attempt to implement RAISE_VARARGS (with args=1 so far only). --- py/vm.c | 7 +++++++ tests/basics/tests/try1.py | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/py/vm.c b/py/vm.c index 5e3ec0baf8..e2bb3de642 100644 --- a/py/vm.c +++ b/py/vm.c @@ -474,6 +474,13 @@ bool mp_execute_byte_code_2(const byte **ip_in_out, mp_obj_t *fastn, mp_obj_t ** assert(exc_sp == &exc_stack[0] - 1); return false; + case MP_BC_RAISE_VARARGS: + unum = *ip++; + assert(unum == 1); + obj1 = POP(); + nlr_jump(obj1); + return false; + case MP_BC_YIELD_VALUE: nlr_pop(); *ip_in_out = ip; diff --git a/tests/basics/tests/try1.py b/tests/basics/tests/try1.py index b3b85372d7..56d3075041 100644 --- a/tests/basics/tests/try1.py +++ b/tests/basics/tests/try1.py @@ -4,3 +4,8 @@ try: x.a() except: print(x) + +try: + raise IndexError +except IndexError: + print("caught")