summaryrefslogtreecommitdiff
path: root/py/vm.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-02-15 16:10:44 +0000
committerDamien George <damien.p.george@gmail.com>2014-02-15 16:10:44 +0000
commitc5966128c7c8a768f6726f299d85d5daef6bed48 (patch)
treefea6913ae43d722078a837d8c7fd9a1e459f3891 /py/vm.c
parenta71c83a1d1aeca1d81d7c673929f8e836dec131e (diff)
Implement proper exception type hierarchy.
Each built-in exception is now a type, with base type BaseException. C exceptions are created by passing a pointer to the exception type to make an instance of. When raising an exception from the VM, an instance is created automatically if an exception type is raised (as opposed to an exception instance). Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper. Handling of parse error changed to match new exceptions. mp_const_type renamed to mp_type_type for consistency.
Diffstat (limited to 'py/vm.c')
-rw-r--r--py/vm.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/py/vm.c b/py/vm.c
index 1fc5b4a57..461fecbda 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -371,7 +371,7 @@ unwind_jump:
// if TOS is None, just pops it and continues
// if TOS is an integer, does something else
// else error
- if (MP_OBJ_IS_TYPE(TOP(), &exception_type)) {
+ if (mp_obj_is_exception_instance(TOP())) {
nlr_jump(TOP());
}
if (TOP() == mp_const_none) {
@@ -575,7 +575,7 @@ unwind_return:
unum = *ip++;
assert(unum == 1);
obj1 = POP();
- nlr_jump(obj1);
+ nlr_jump(rt_make_raise_obj(obj1));
case MP_BC_YIELD_VALUE:
nlr_pop();
@@ -613,7 +613,7 @@ unwind_return:
// set file and line number that the exception occurred at
// TODO: don't set traceback for exceptions re-raised by END_FINALLY.
// But consider how to handle nested exceptions.
- if (MP_OBJ_IS_TYPE(nlr.ret_val, &exception_type)) {
+ if (mp_obj_is_exception_instance(nlr.ret_val)) {
machine_uint_t code_info_size = code_info[0] | (code_info[1] << 8) | (code_info[2] << 16) | (code_info[3] << 24);
qstr source_file = code_info[4] | (code_info[5] << 8) | (code_info[6] << 16) | (code_info[7] << 24);
qstr block_name = code_info[8] | (code_info[9] << 8) | (code_info[10] << 16) | (code_info[11] << 24);