Skip to content

Commit 180045b

Browse files
committed
zephyr/main: Move lexer constructor to within NLR handler block.
And raise an exception when mp_lexer_new_from_file is called.
1 parent 25b6b62 commit 180045b

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

zephyr/main.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,9 @@
4444
#include "lib/mp-readline/readline.h"
4545

4646
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
47-
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
48-
if (lex == NULL) {
49-
printf("MemoryError: lexer could not allocate memory\n");
50-
return;
51-
}
52-
5347
nlr_buf_t nlr;
5448
if (nlr_push(&nlr) == 0) {
49+
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
5550
qstr source_name = lex->source_name;
5651
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
5752
mp_obj_t module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, true);
@@ -130,7 +125,7 @@ void gc_collect(void) {
130125
}
131126

132127
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
133-
return NULL;
128+
mp_raise_OSError(ENOENT);
134129
}
135130

136131
mp_import_stat_t mp_import_stat(const char *path) {

0 commit comments

Comments
 (0)