aboutsummaryrefslogtreecommitdiff
path: root/py/builtinimport.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-10-17 12:17:37 +1100
committerDamien George <damien.p.george@gmail.com>2016-10-17 12:17:37 +1100
commit7d0d7215d2575a2d36d34c9a13b58cade0610a28 (patch)
tree6690dc711d4489811dfef4f01a26ae12ccf36dd0 /py/builtinimport.c
parent6caca3259f4ec8f298b1d35f15e4492efbcff6b1 (diff)
py: Use mp_raise_msg helper function where appropriate.
Saves the following number of bytes of code space: 176 for bare-arm, 352 for minimal, 272 for unix x86-64, 140 for stmhal, 120 for esp8266.
Diffstat (limited to 'py/builtinimport.c')
-rw-r--r--py/builtinimport.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index e4199f25d..e72eaf472 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -138,7 +138,7 @@ STATIC void do_load_from_lexer(mp_obj_t module_obj, mp_lexer_t *lex, const char
if (lex == NULL) {
// we verified the file exists using stat, but lexer could still fail
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ImportError, "module not found"));
+ mp_raise_msg(&mp_type_ImportError, "module not found");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError,
"no module named '%s'", fname));
@@ -340,7 +340,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
DEBUG_printf("Warning: no dots in current module name and level>0\n");
p = this_name + this_name_l;
} else if (level != -1) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ImportError, "Invalid relative import"));
+ mp_raise_msg(&mp_type_ImportError, "invalid relative import");
}
uint new_mod_l = (mod_len == 0 ? (size_t)(p - this_name) : (size_t)(p - this_name) + 1 + mod_len);
@@ -355,7 +355,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
DEBUG_printf("Resolved base name for relative import: '%s'\n", qstr_str(new_mod_q));
if (new_mod_q == MP_QSTR_) {
// CPython raises SystemError
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ImportError, "cannot perform relative import"));
+ mp_raise_msg(&mp_type_ImportError, "cannot perform relative import");
}
module_name = MP_OBJ_NEW_QSTR(new_mod_q);
mod_str = new_mod;
@@ -425,7 +425,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
#endif
// couldn't find the file, so fail
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ImportError, "module not found"));
+ mp_raise_msg(&mp_type_ImportError, "module not found");
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError,
"no module named '%q'", mod_name));