diff options
author | Damien George <damien.p.george@gmail.com> | 2017-03-14 11:25:21 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-03-14 11:52:05 +1100 |
commit | bcd5adc65e341180bd6411d7008ea36e225bddf9 (patch) | |
tree | 4e5d32e8143e019f347dfcee0329f7c9e6738b56 | |
parent | c72a5f8c79514ac93b62e1a767a5d413105d7dd6 (diff) |
minimal/main: Move lexer constructor to within NLR handler block.
And raise an exception when mp_lexer_new_from_file is called.
-rw-r--r-- | minimal/main.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/minimal/main.c b/minimal/main.c index 766ad6c1b..496d925e7 100644 --- a/minimal/main.c +++ b/minimal/main.c @@ -7,18 +7,14 @@ #include "py/runtime.h" #include "py/repl.h" #include "py/gc.h" +#include "py/mperrno.h" #include "lib/utils/pyexec.h" #if MICROPY_ENABLE_COMPILER void do_str(const char *src, mp_parse_input_kind_t input_kind) { - mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0); - if (lex == NULL) { - printf("MemoryError: lexer could not allocate memory\n"); - return; - } - nlr_buf_t nlr; if (nlr_push(&nlr) == 0) { + mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0); qstr source_name = lex->source_name; mp_parse_tree_t parse_tree = mp_parse(lex, input_kind); mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true); @@ -74,7 +70,7 @@ void gc_collect(void) { } mp_lexer_t *mp_lexer_new_from_file(const char *filename) { - return NULL; + mp_raise_OSError(MP_ENOENT); } mp_import_stat_t mp_import_stat(const char *path) { |