summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/import/import_override.py4
-rw-r--r--tests/import/pkg7/subpkg1/subpkg2/mod3.py4
2 files changed, 7 insertions, 1 deletions
diff --git a/tests/import/import_override.py b/tests/import/import_override.py
index 029ebe54c..0144e78cb 100644
--- a/tests/import/import_override.py
+++ b/tests/import/import_override.py
@@ -2,6 +2,10 @@
def custom_import(name, globals, locals, fromlist, level):
+ # CPython always tries to import _io, so just let that through as-is.
+ if name == "_io":
+ return orig_import(name, globals, locals, fromlist, level)
+
print("import", name, fromlist, level)
class M:
diff --git a/tests/import/pkg7/subpkg1/subpkg2/mod3.py b/tests/import/pkg7/subpkg1/subpkg2/mod3.py
index b0f4279fc..f7f4c1e65 100644
--- a/tests/import/pkg7/subpkg1/subpkg2/mod3.py
+++ b/tests/import/pkg7/subpkg1/subpkg2/mod3.py
@@ -5,7 +5,9 @@ print(mod1.foo)
print(bar)
# attempted relative import beyond top-level package
+# On older versions of CPython (eg 3.8) this is a ValueError, but on
+# newer CPython (eg 3.11) and MicroPython it's an ImportError.
try:
from .... import mod1
-except ImportError:
+except (ImportError, ValueError):
print("ImportError")