Message297608
https://docs.python.org/3/reference/simple_stmts.html#the-import-statement defers the full specification of relative imports to PEP 328. PEP 328 gives the example "from ...sys import path" in a second-level package, and notes "while that last case is legal, it is certainly discouraged".
However, in the current implementation it actually isn't legal. Using a stdlib second-level package to test:
Python 3.5.3 (default, Apr 10 2017, 07:53:16) [GCC 6.3.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xml.dom
>>> __package__ = "xml.dom"
>>> from . import minidom # Works fine
>>> from ...sys import path
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: attempted relative import beyond top-level package
Either the documentation or the implementation should be fixed. |
|
Date |
User |
Action |
Args |
2017-07-03 19:14:52 | Malcolm Smith | set | recipients:
+ Malcolm Smith |
2017-07-03 19:14:52 | Malcolm Smith | set | messageid: <1499109292.04.0.970471813466.issue30840@psf.upfronthosting.co.za> |
2017-07-03 19:14:52 | Malcolm Smith | link | issue30840 messages |
2017-07-03 19:14:51 | Malcolm Smith | create | |
|