diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-02 01:51:25 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-02 02:00:47 +0300 |
commit | d8351ca8a066d0ca607d78220b7476551f036fd1 (patch) | |
tree | 1bbfdf9f0fc3e19c65062794bd98604f2e2de9e8 /py/objexcept.c | |
parent | f2021ffe0f1d7d7e373b4e8739a493c9bd4e43ef (diff) | |
download | micropython-d8351ca8a066d0ca607d78220b7476551f036fd1.tar.gz micropython-d8351ca8a066d0ca607d78220b7476551f036fd1.zip |
objtype: .print() Exception instances in adhoc way.
This is ugly, just as expected.
Diffstat (limited to 'py/objexcept.c')
-rw-r--r-- | py/objexcept.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/py/objexcept.c b/py/objexcept.c index 160cf09fd4..60e15b6dba 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -30,12 +30,17 @@ const mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, STATIC void mp_obj_exception_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) { mp_obj_exception_t *o = o_in; - if (kind == PRINT_REPR) { + mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS; + bool is_subclass = kind & PRINT_EXC_SUBCLASS; + if (!is_subclass && (k == PRINT_REPR || k == PRINT_EXC)) { print(env, "%s", qstr_str(o->base.type->name)); - } else if (kind == PRINT_EXC) { - print(env, "%s: ", qstr_str(o->base.type->name)); } - if (kind == PRINT_STR || kind == PRINT_EXC) { + + if (k == PRINT_EXC) { + print(env, ": "); + } + + if (k == PRINT_STR || k == PRINT_EXC) { if (o->args == NULL || o->args->len == 0) { print(env, ""); return; @@ -47,7 +52,7 @@ STATIC void mp_obj_exception_print(void (*print)(void *env, const char *fmt, ... tuple_print(print, env, o->args, kind); } -STATIC mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { +mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { mp_obj_type_t *type = type_in; if (n_kw != 0) { |