From d0f5e61ab58892ecd3b0838adeea3cde330da3f1 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 25 Jul 2014 11:00:15 +0300 Subject: py: Implement __file__ attribute for modules. --- unix/main.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'unix') diff --git a/unix/main.c b/unix/main.c index d0222de0d..03718c22e 100644 --- a/unix/main.c +++ b/unix/main.c @@ -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); /* -- cgit v1.2.3