py: Implement __file__ attribute for modules.

This commit is contained in:
Paul Sokolovsky
2014-07-25 11:00:15 +03:00
parent 645582fe14
commit d0f5e61ab5
5 changed files with 18 additions and 0 deletions

View File

@@ -95,6 +95,11 @@ STATIC int execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind,
}
qstr source_name = mp_lexer_source_name(lex);
#if MICROPY_PY___FILE__
if (input_kind == MP_PARSE_FILE_INPUT) {
mp_store_global(MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name));
}
#endif
mp_lexer_free(lex);
/*