Brett Cannon <br...@python.org> added the comment:
If you run with `-Xdev`/warnings turned on you get an idea of what's happening: >>> builtins.__import__('', globals(), locals(), ('foo',), 1) <stdin>:1: ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__ <module '__main__' (built-in)> The check is being done in resolve_name() in import.c (https://github.com/python/cpython/blob/f9f8e3ce709ceb15c8db8c8dde940daf1febf13d/Python/import.c#L1543). My guess is there's an off-by-one error in the sanity check logic for attempting a relative import beyond the top-level package. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37409> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com