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 brett.cannon, eric.snow, fossilet
Date 2015-07-30.17:00:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1438275614.19.0.982648965928.issue24752@psf.upfronthosting.co.za>
In-reply-to
Content
It's that way because that's how import.c has it coded in Python 2.7: https://hg.python.org/cpython/file/309cbbc32491/Python/import.c#l2462 . Here is how it looks in Python 2:

%%python2
from __future__ import absolute_import
from . import foo
-----------------------------------------------------
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
ValueError: Attempted relative import in non-package


I think another sanity check needs to be added to https://github.com/python/cpython/blob/829b49cbd2e4b1d573470da79ca844b730120f3d/Lib/importlib/_bootstrap.py#L919 for when __package__ is None but level > 0 and then raise the ValueError like in Python 2.
History
Date User Action Args
2015-07-30 17:00:14brett.cannonsetrecipients: + brett.cannon, fossilet, eric.snow
2015-07-30 17:00:14brett.cannonsetmessageid: <1438275614.19.0.982648965928.issue24752@psf.upfronthosting.co.za>
2015-07-30 17:00:14brett.cannonlinkissue24752 messages
2015-07-30 17:00:13brett.cannoncreate