diff options
| author | Chris Liechti <cliechti@gmx.net> | 2020-11-30 16:40:56 +0100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-11-21 00:01:01 +1100 |
| commit | 48d96b400e73e7fbcca8365d0bebc0c41402dde5 (patch) | |
| tree | b8c555c47655b4e939cd240f510365c1c4a4b269 /tests/import/builtin_import.py | |
| parent | c07fda73f7115d2d2d4e2d4bba00a3e8dfd1367e (diff) | |
py/builtinimport: Support relative import in custom __import__ callback.
The globals need to be forwarded from the caller's context.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/import/builtin_import.py')
| -rw-r--r-- | tests/import/builtin_import.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/import/builtin_import.py b/tests/import/builtin_import.py index 734498d1b..364b0bae9 100644 --- a/tests/import/builtin_import.py +++ b/tests/import/builtin_import.py @@ -20,3 +20,12 @@ try: __import__("xyz", None, None, None, -1) except ValueError: print("ValueError") + +# globals is not checked for level=0 +__import__("builtins", "globals") + +# globals must be a dict (or None) for level>0 +try: + __import__("builtins", "globals", None, None, 1) +except TypeError: + print("TypeError") |
