diff --git a/py/builtinimport.c b/py/builtinimport.c index 4024c5d59a..0e3f160a73 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -360,8 +360,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { qstr new_mod_q = qstr_from_strn(new_mod, new_mod_l); DEBUG_printf("Resolved base name for relative import: '%s'\n", qstr_str(new_mod_q)); if (new_mod_q == MP_QSTR_) { - // CPython raises SystemError - mp_raise_msg(&mp_type_ImportError, "cannot perform relative import"); + mp_raise_msg(&mp_type_ValueError, "cannot perform relative import"); } module_name = MP_OBJ_NEW_QSTR(new_mod_q); mod_str = new_mod; diff --git a/tests/import/pkg7/subpkg1/subpkg2/mod3.py b/tests/import/pkg7/subpkg1/subpkg2/mod3.py index 747cde03b6..7ed69bdee9 100644 --- a/tests/import/pkg7/subpkg1/subpkg2/mod3.py +++ b/tests/import/pkg7/subpkg1/subpkg2/mod3.py @@ -7,5 +7,5 @@ print(bar) # whereas CPython raises a ValueError try: from .... import mod1 -except (ImportError, ValueError): - print('Error') +except ValueError: + print('ValueError')