diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-18 23:24:36 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-18 23:24:36 +0000 |
commit | 08335004cfe95048ee06134a3e49b9fb75639139 (patch) | |
tree | 7518a854012938fd70c57b3571a630a142b84f28 /py/builtinimport.c | |
parent | aefe79880f8c5f66132673ccc9be27d2ca29005b (diff) |
Add source file name and line number to error messages.
Byte code has a map from byte-code offset to source-code line number,
used to give better error messages.
Diffstat (limited to 'py/builtinimport.c')
-rw-r--r-- | py/builtinimport.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c index 2eca36fbc..e3c630a0a 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -51,6 +51,7 @@ mp_obj_t mp_builtin___import__(int n_args, mp_obj_t *args) { qstr parse_exc_id; const char *parse_exc_msg; mp_parse_node_t pn = mp_parse(lex, MP_PARSE_FILE_INPUT, &parse_exc_id, &parse_exc_msg); + qstr source_name = mp_lexer_source_name(lex); mp_lexer_free(lex); if (pn == MP_PARSE_NODE_NULL) { @@ -61,7 +62,7 @@ mp_obj_t mp_builtin___import__(int n_args, mp_obj_t *args) { } // compile the imported script - mp_obj_t module_fun = mp_compile(pn, false); + mp_obj_t module_fun = mp_compile(pn, source_name, false); if (module_fun == mp_const_none) { // TODO handle compile error correctly |