aboutsummaryrefslogtreecommitdiff
path: root/py/builtinimport.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2019-09-26 22:52:04 +1000
committerDamien George <damien.p.george@gmail.com>2020-04-05 14:11:51 +1000
commita9a745e4b4838749a47857f1d0c95de52dc85f58 (patch)
tree60469e58476c5a68999ad0a2e8d58dbca8a6abb8 /py/builtinimport.c
parent312c699491830daacd33f032a6d6fc6cc6ff0c96 (diff)
py: Use preprocessor to detect error reporting level (terse/detailed).
Instead of compiler-level if-logic. This is necessary to know what error strings are included in the build at the preprocessor stage, so that string compression can be implemented.
Diffstat (limited to 'py/builtinimport.c')
-rw-r--r--py/builtinimport.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c
index b188f3c34..50106a88e 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -396,11 +396,11 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
#endif
if (module_obj == MP_OBJ_NULL) {
// couldn't find the file, so fail
- if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
- mp_raise_msg(&mp_type_ImportError, "module not found");
- } else {
- mp_raise_msg_varg(&mp_type_ImportError, "no module named '%q'", mod_name);
- }
+ #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
+ mp_raise_msg(&mp_type_ImportError, "module not found");
+ #else
+ mp_raise_msg_varg(&mp_type_ImportError, "no module named '%q'", mod_name);
+ #endif
}
} else {
// found the file, so get the module
@@ -499,11 +499,11 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
#endif
// Couldn't find the module, so fail
- if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
- mp_raise_msg(&mp_type_ImportError, "module not found");
- } else {
- mp_raise_msg_varg(&mp_type_ImportError, "no module named '%q'", module_name_qstr);
- }
+ #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
+ mp_raise_msg(&mp_type_ImportError, "module not found");
+ #else
+ mp_raise_msg_varg(&mp_type_ImportError, "no module named '%q'", module_name_qstr);
+ #endif
}
#endif // MICROPY_ENABLE_EXTERNAL_IMPORT