py: Make compiler return a proper exception on SyntaxError.

This commit is contained in:
Damien George
2014-10-05 19:01:34 +01:00
parent 6dba992182
commit a91ac2011f
10 changed files with 53 additions and 37 deletions

View File

@@ -64,9 +64,9 @@ STATIC mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse
// compile the string
mp_obj_t module_fun = mp_compile(pn, source_name, MP_EMIT_OPT_NONE, false);
if (module_fun == mp_const_none) {
// TODO handle compile error correctly
return mp_const_none;
// check if there was a compile error
if (mp_obj_is_exception_instance(module_fun)) {
nlr_raise(module_fun);
}
// complied successfully, execute it