diff options
author | Damien George <damien.p.george@gmail.com> | 2017-03-14 11:36:24 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-03-14 11:52:05 +1100 |
commit | 41b1df604617bdde59bb722b9247c16fa4677d94 (patch) | |
tree | a492f793b1f64107e8ebc68b8d46068a296fb99a | |
parent | 21420b13c011ca5a89a224ff7108b98fd3aeafd9 (diff) | |
download | micropython-41b1df604617bdde59bb722b9247c16fa4677d94.tar.gz micropython-41b1df604617bdde59bb722b9247c16fa4677d94.zip |
lib/memzip: Make lexer constructor raise exception when file not found.
-rw-r--r-- | lib/memzip/lexermemzip.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/memzip/lexermemzip.c b/lib/memzip/lexermemzip.c index 72fe6b1c6b..6b26961bdc 100644 --- a/lib/memzip/lexermemzip.c +++ b/lib/memzip/lexermemzip.c @@ -1,6 +1,8 @@ #include <stdlib.h> #include "py/lexer.h" +#include "py/runtime.h" +#include "py/mperrno.h" #include "memzip.h" mp_lexer_t *mp_lexer_new_from_file(const char *filename) @@ -9,7 +11,7 @@ mp_lexer_t *mp_lexer_new_from_file(const char *filename) size_t len; if (memzip_locate(filename, &data, &len) != MZ_OK) { - return NULL; + mp_raise_OSError(MP_ENOENT); } return mp_lexer_new_from_str_len(qstr_from_str(filename), (const char *)data, (mp_uint_t)len, 0); |