diff options
author | Damien George <damien.p.george@gmail.com> | 2015-04-11 13:03:37 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-04-16 14:30:16 +0000 |
commit | 044c473de203b4dbe93874813b430fb6336db2b2 (patch) | |
tree | f632b62412031458b7a9438fa144ef5a6ebd1f66 /py/objexcept.c | |
parent | e72cda99fd5fc9e7c6476eb8574c4401d3ef9560 (diff) |
py: Add %q format support to mp_[v]printf, and use it.
Diffstat (limited to 'py/objexcept.c')
-rw-r--r-- | py/objexcept.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/py/objexcept.c b/py/objexcept.c index 8a008d1ff..4623e7318 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -95,7 +95,7 @@ STATIC void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_pr 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)) { - mp_printf(print, "%s", qstr_str(o->base.type->name)); + mp_print_str(print, qstr_str(o->base.type->name)); } if (k == PRINT_EXC) { @@ -321,13 +321,17 @@ mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char uint max_len = MP_STATE_VM(mp_emergency_exception_buf) + mp_emergency_exception_buf_size - str_data; + vstr_t vstr; + vstr_init_fixed_buf(&vstr, max_len, (char *)str_data); + va_list ap; va_start(ap, fmt); - str->len = vsnprintf((char *)str_data, max_len, fmt, ap); + vstr_vprintf(&vstr, fmt, ap); va_end(ap); str->base.type = &mp_type_str; str->hash = qstr_compute_hash(str_data, str->len); + str->len = vstr.len; str->data = str_data; o->args = tuple; |