Brett Cannon added the comment:

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.

----------
stage: needs patch -> test needed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24752>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to