py: Improve exception bases, reduces ROM usage.

Thanks to @pfalcon for the tip!
This commit is contained in:
Damien George
2014-02-15 21:05:25 +00:00
parent 8725f8f7de
commit 22a0865d54
2 changed files with 23 additions and 17 deletions

View File

@@ -1003,6 +1003,8 @@ mp_obj_t rt_make_raise_obj(mp_obj_t o) {
if (mp_obj_is_exception_type(o)) {
// o is an exception type (it is derived from BaseException (or is BaseException))
// create and return a new exception instance by calling o
// TODO could have an option to disable traceback, then builtin exceptions (eg TypeError)
// could have const instances in ROM which we return here instead
return rt_call_function_n_kw(o, 0, 0, NULL);
} else if (mp_obj_is_exception_instance(o)) {
// o is an instance of an exception, so use it as the exception