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 Malcolm Smith
Recipients Malcolm Smith
Date 2017-07-03.19:14:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1499109292.04.0.970471813466.issue30840@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-07-03 19:14:52Malcolm Smithsetrecipients: + Malcolm Smith
2017-07-03 19:14:52Malcolm Smithsetmessageid: <1499109292.04.0.970471813466.issue30840@psf.upfronthosting.co.za>
2017-07-03 19:14:52Malcolm Smithlinkissue30840 messages
2017-07-03 19:14:51Malcolm Smithcreate