Skip to content

Commit db0a836

Browse files
jeplerdpgeorge
authored andcommitted
py/profile: Fix printing lineno in frame objects.
The argument corresponding to a `%q` specifier must be of type `qstr`, not a narrower type like `int16_t`. Not ensuring this caused an assertion error on one Windows x64 build. The argument corresponding to a `%d` specifier must be of type `int`, not a potentially-wider type like `mp_uint_t`. Not ensuring this prevented the function name from being printed on the unix nanbox build. Signed-off-by: Jeff Epler <jepler@gmail.com>
1 parent f33f1aa commit db0a836

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

py/objcode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static inline const void *mp_code_get_proto_fun(mp_obj_code_t *self) {
7272

7373
#include "py/emitglue.h"
7474

75-
#define MP_CODE_QSTR_MAP(context, idx) (context->constants.qstr_table[idx])
75+
#define MP_CODE_QSTR_MAP(context, idx) ((qstr)(context->constants.qstr_table[idx]))
7676

7777
typedef struct _mp_obj_code_t {
7878
// TODO this was 4 words

py/profile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static void frame_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
8080
"<frame at 0x%p, file '%q', line %d, code %q>",
8181
frame,
8282
MP_CODE_QSTR_MAP(code->context, 0),
83-
frame->lineno,
83+
(int)frame->lineno,
8484
MP_CODE_QSTR_MAP(code->context, prelude->qstr_block_name_idx)
8585
);
8686
}

0 commit comments

Comments
 (0)