Make %p include the 0x prefix

.. and modify some messages where 0x was specified "manually".

This involves updating some tests to expect the new 0x to appear.
This commit is contained in:
Jeff Epler 2021-08-29 11:14:19 -05:00
parent 68af5fd040
commit db3945edfe
5 changed files with 16 additions and 11 deletions

View File

@ -545,7 +545,12 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
case 'p':
case 'P': // don't bother to handle upcase for 'P'
// Use unsigned long int to work on both ILP32 and LP64 systems
chrs += mp_print_int(print, va_arg(args, unsigned long int), 0, 16, 'a', flags, fill, width);
#if SUPPORT_INT_BASE_PREFIX
chrs += mp_print_int(print, va_arg(args, unsigned long int), 0, 16, 'a', flags | PF_FLAG_SHOW_PREFIX, fill, width);
#else
print->print_strn(print->data, "0x", 2);
chrs += mp_print_int(print, va_arg(args, unsigned long int), 0, 16, 'a', flags, fill, width) + 2;
#endif
break;
#if MICROPY_PY_BUILTINS_FLOAT
case 'e':

View File

@ -182,7 +182,7 @@ qstr mp_obj_fun_get_name(mp_const_obj_t fun_in) {
STATIC void fun_bc_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_fun_bc_t *o = MP_OBJ_TO_PTR(o_in);
mp_printf(print, "<function %q at 0x%p>", mp_obj_fun_get_name(o_in), o);
mp_printf(print, "<function %q at %p>", mp_obj_fun_get_name(o_in), o);
}
#endif

View File

@ -68,7 +68,7 @@ STATIC void code_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
const mp_raw_code_t *rc = o->rc;
const mp_bytecode_prelude_t *prelude = &rc->prelude;
mp_printf(print,
"<code object %q at 0x%p, file \"%q\", line %d>",
"<code object %q at %p, file \"%q\", line %d>",
prelude->qstr_block_name,
o,
prelude->qstr_source_file,
@ -202,7 +202,7 @@ STATIC void frame_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
const mp_raw_code_t *rc = code->rc;
const mp_bytecode_prelude_t *prelude = &rc->prelude;
mp_printf(print,
"<frame at 0x%p, file '%q', line %d, code %q>",
"<frame at %p, file '%q', line %d, code %q>",
frame,
prelude->qstr_source_file,
frame->lineno,
@ -950,7 +950,7 @@ void mp_prof_print_instr(const byte *ip, mp_code_state_t *code_state) {
/* long path */ if (1) {
mp_printf(&mp_plat_print,
"@0x%p:%q:%q+0x%04x:%d",
"@%p:%q:%q+0x%04x:%d",
ip,
prelude->qstr_source_file,
prelude->qstr_block_name,

View File

@ -1,4 +1,4 @@
<struct STRUCT 0>
<struct ERROR 0>
<struct ARRAY 0>
<struct PTR 0>
<struct STRUCT 0x0>
<struct ERROR 0x0>
<struct ARRAY 0x0>
<struct PTR 0x0>

View File

@ -15,8 +15,8 @@ false true
abc
%
# GC
0
0
0x0
0x0
# vstr
tests
sts