diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-21 01:15:20 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-02-21 01:15:20 +0200 |
commit | feacaa12ac22666e4bb005cc250cc96f0be53840 (patch) | |
tree | 81da503854daff7be30b53c2f38eef4402a4b2df | |
parent | a8d31b28bcf640579c013eeeb2e814c317e59111 (diff) | |
download | micropython-feacaa12ac22666e4bb005cc250cc96f0be53840.tar.gz micropython-feacaa12ac22666e4bb005cc250cc96f0be53840.zip |
__import__: Catch relative import attempts and throw NotImplementedError.
-rw-r--r-- | py/builtinimport.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c index 05b8eead57..e64ca82374 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -140,8 +140,17 @@ mp_obj_t mp_builtin___import__(int n_args, mp_obj_t *args) { */ mp_obj_t fromtuple = mp_const_none; + int level = 0; if (n_args >= 4) { fromtuple = args[3]; + if (n_args >= 5) { + level = MP_OBJ_SMALL_INT_VALUE(args[4]); + } + } + + if (level != 0) { + nlr_jump(mp_obj_new_exception_msg(&mp_type_NotImplementedError, + "Relative import is not implemented")); } uint mod_len; |