summaryrefslogtreecommitdiff
path: root/py/builtinimport.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-11-06 17:36:16 +0000
committerDamien George <damien.p.george@gmail.com>2014-11-06 17:36:16 +0000
commit1e9a92f84fb58db610e20b766052292edc28d25b (patch)
tree0005072b03a413c4b01df72f61066e0aaeca23f3 /py/builtinimport.c
parentb6b34cd3f6585eed455473bc149e9db758a45d9c (diff)
py: Use shorter, static error msgs when ERROR_REPORTING_TERSE enabled.
Going from MICROPY_ERROR_REPORTING_NORMAL to MICROPY_ERROR_REPORTING_TERSE now saves 2020 bytes ROM for ARM Thumb2, and 2200 bytes ROM for 32-bit x86. This is about a 2.5% code size reduction for bare-arm.
Diffstat (limited to 'py/builtinimport.c')
-rw-r--r--py/builtinimport.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 7ecf0919b..c96a7d4ae 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -118,7 +118,12 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) {
if (lex == NULL) {
// we verified the file exists using stat, but lexer could still fail
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError, "No module named '%s'", vstr_str(file)));
+ if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
+ nlr_raise(mp_obj_new_exception_msg(&mp_type_ImportError, "module not found"));
+ } else {
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError,
+ "no module named '%s'", vstr_str(file)));
+ }
}
#if MICROPY_PY___FILE__
@@ -277,7 +282,12 @@ mp_obj_t mp_builtin___import__(mp_uint_t n_args, const mp_obj_t *args) {
{
#endif
// couldn't find the file, so fail
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError, "No module named '%s'", qstr_str(mod_name)));
+ if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
+ nlr_raise(mp_obj_new_exception_msg(&mp_type_ImportError, "module not found"));
+ } else {
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError,
+ "no module named '%s'", qstr_str(mod_name)));
+ }
}
} else {
// found the file, so get the module