Skip to content

Commit d2f645d

Browse files
committed
Restore setting __file__ in parse_compile_execute
This seems to have been lost, possibly in a merge. Closes: #8881
1 parent 2e29772 commit d2f645d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

shared/runtime/pyexec.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
117117
}
118118
// source is a lexer, parse and compile the script
119119
qstr source_name = lex->source_name;
120+
// CIRCUITPY-CHANGE
121+
#if MICROPY_PY___FILE__
122+
if (input_kind == MP_PARSE_FILE_INPUT) {
123+
mp_store_global(MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
124+
}
125+
#endif
126+
120127
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
121128
module_fun = mp_compile(&parse_tree, source_name, exec_flags & EXEC_FLAG_IS_REPL);
122129
#else

0 commit comments

Comments
 (0)