summaryrefslogtreecommitdiffstatshomepage
path: root/py/builtinevex.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-02-15 00:02:27 +0000
committerDamien George <damien.p.george@gmail.com>2015-02-15 00:02:27 +0000
commit0868942e7722f73f53fe9c8b730fd3acc9f2d2e7 (patch)
tree64d5127104517526a26db7cc0bbf38ffe7899514 /py/builtinevex.c
parent1b8e76b8e64ff801d11c6f420158f10c5b13c4ff (diff)
downloadmicropython-0868942e7722f73f53fe9c8b730fd3acc9f2d2e7.tar.gz
micropython-0868942e7722f73f53fe9c8b730fd3acc9f2d2e7.zip
py: Check for valid file when creating lexer for execfile.
Addresses issue #1119.
Diffstat (limited to 'py/builtinevex.c')
-rw-r--r--py/builtinevex.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/py/builtinevex.c b/py/builtinevex.c
index 85ffbf4e65..4cafc5ecfe 100644
--- a/py/builtinevex.c
+++ b/py/builtinevex.c
@@ -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);