This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brett.cannon
Recipients Ben Lewis2, brett.cannon, eric.smith, serhiy.storchaka
Date 2019-06-28.19:34:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561750499.23.0.270390006821.issue37409@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-06-28 19:34:59brett.cannonsetrecipients: + brett.cannon, eric.smith, serhiy.storchaka, Ben Lewis2
2019-06-28 19:34:59brett.cannonsetmessageid: <1561750499.23.0.270390006821.issue37409@roundup.psfhosted.org>
2019-06-28 19:34:59brett.cannonlinkissue37409 messages
2019-06-28 19:34:59brett.cannoncreate