Skip to content
Snippets Groups Projects
Commit 0868942e authored by Damien George's avatar Damien George
Browse files

py: Check for valid file when creating lexer for execfile.

Addresses issue #1119.
parent 1b8e76b8
Branches
No related tags found
No related merge requests found
......@@ -134,6 +134,9 @@ STATIC mp_obj_t eval_exec_helper(mp_uint_t n_args, const mp_obj_t *args, mp_pars
mp_lexer_t *lex;
if (MICROPY_PY_BUILTINS_EXECFILE && parse_input_kind == MP_PARSE_SINGLE_INPUT) {
lex = mp_lexer_new_from_file(str);
if (lex == NULL) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "could not open file '%s'", str));
}
parse_input_kind = MP_PARSE_FILE_INPUT;
} else {
lex = mp_lexer_new_from_str_len(MP_QSTR__lt_string_gt_, str, str_len, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment