Skip to content

Commit 11ecd40

Browse files
authored
Merge pull request #10629 from dhalbert/verbose-import-error
py/builtinimport.c: always name module in error msg when an import fails
2 parents c382b55 + 0013b48 commit 11ecd40

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

py/builtinimport.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@ static mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name,
451451

452452
if (stat == MP_IMPORT_STAT_NO_EXIST) {
453453
// Not found -- fail.
454-
#if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
454+
// CIRCUITPY-CHANGE: always the use more verbose error message that names missing module.
455+
// Otherwise `import a` where `a` imports `b`, but `b` is missing will give a confusing error.
456+
#if 0 && (MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE)
455457
mp_raise_msg(&mp_type_ImportError, MP_ERROR_TEXT("module not found"));
456458
#else
457459
mp_raise_msg_varg(&mp_type_ImportError, MP_ERROR_TEXT("no module named '%q'"), full_mod_name);

0 commit comments

Comments
 (0)