mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +01:00
py: Implement compile builtin, enabled only on unix port.
This should be pretty compliant with CPython, except perhaps for some corner cases to do with globals/locals context. Addresses issue #879.
This commit is contained in:
@@ -1189,6 +1189,13 @@ mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_i
|
||||
nlr_raise(module_fun);
|
||||
}
|
||||
|
||||
// for compile only
|
||||
if (MICROPY_PY_BUILTINS_COMPILE && globals == NULL) {
|
||||
mp_globals_set(old_globals);
|
||||
mp_locals_set(old_locals);
|
||||
return module_fun;
|
||||
}
|
||||
|
||||
// complied successfully, execute it
|
||||
nlr_buf_t nlr;
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user