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.
This commit is contained in:
Jim Mussared
2019-09-26 22:52:04 +10:00
committed by Damien George
parent 312c699491
commit a9a745e4b4
11 changed files with 384 additions and 380 deletions

View File

@@ -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