Skip to content

Commit e9b4b7a

Browse files
committed
Merge pull request adafruit#135 from pfalcon/simple-raise
Crude attempt to implement RAISE_VARARGS (with args=1 so far only).
2 parents 46c9e97 + 5388a3c commit e9b4b7a

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

py/vm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,13 @@ bool mp_execute_byte_code_2(const byte **ip_in_out, mp_obj_t *fastn, mp_obj_t **
474474
assert(exc_sp == &exc_stack[0] - 1);
475475
return false;
476476

477+
case MP_BC_RAISE_VARARGS:
478+
unum = *ip++;
479+
assert(unum == 1);
480+
obj1 = POP();
481+
nlr_jump(obj1);
482+
return false;
483+
477484
case MP_BC_YIELD_VALUE:
478485
nlr_pop();
479486
*ip_in_out = ip;

tests/basics/tests/try1.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44
x.a()
55
except:
66
print(x)
7+
8+
try:
9+
raise IndexError
10+
except IndexError:
11+
print("caught")

0 commit comments

Comments
 (0)