Skip to content

Commit 31480fb

Browse files
committed
py/frozenmod: Pass the source name of the frozen module to the lexer.
This allows for better error messages, since the name of the file (sans .py) can now be printed when an exception occurs within a frozen script.
1 parent 5e247a5 commit 31480fb

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

py/frozenmod.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ STATIC mp_lexer_t *mp_find_frozen_str(const char *str, size_t len) {
5050
for (int i = 0; *name != 0; i++) {
5151
size_t l = strlen(name);
5252
if (l == len && !memcmp(str, name, l)) {
53-
mp_lexer_t *lex = MICROPY_MODULE_FROZEN_LEXER(MP_QSTR_, mp_frozen_str_content + offset, mp_frozen_str_sizes[i], 0);
53+
qstr source = qstr_from_strn(name, l);
54+
mp_lexer_t *lex = MICROPY_MODULE_FROZEN_LEXER(source, mp_frozen_str_content + offset, mp_frozen_str_sizes[i], 0);
5455
return lex;
5556
}
5657
name += l + 1;

0 commit comments

Comments
 (0)