Skip to content

Commit 9714200

Browse files
committed
mpy-cross/main: Move lexer constructor to within NLR handler block.
1 parent 68e1c4f commit 9714200

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

mpy-cross/main.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,10 @@ STATIC void stderr_print_strn(void *env, const char *str, mp_uint_t len) {
5757
STATIC const mp_print_t mp_stderr_print = {NULL, stderr_print_strn};
5858

5959
STATIC int compile_and_save(const char *file, const char *output_file, const char *source_file) {
60-
mp_lexer_t *lex = mp_lexer_new_from_file(file);
61-
if (lex == NULL) {
62-
printf("could not open file '%s' for reading\n", file);
63-
return 1;
64-
}
65-
6660
nlr_buf_t nlr;
6761
if (nlr_push(&nlr) == 0) {
62+
mp_lexer_t *lex = mp_lexer_new_from_file(file);
63+
6864
qstr source_name;
6965
if (source_file == NULL) {
7066
source_name = lex->source_name;

0 commit comments

Comments
 (0)