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.

classification
Title: Multiple dots in relative import statement raise SyntaxError
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: twouters Nosy List: georg.brandl, twouters, zseil
Priority: normal Keywords:

Created on 2006-05-15 15:26 by zseil, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg28531 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2006-05-15 15:26
When a relative import statement contains more than
one period and no module name, SyntaxError is raised.
Example:

from  .  import  spam       # this works
from  ..spam  import  eggs  # this works
from  ..  import  eggs      # this raises SyntaxError

The problem is in the following line in Grammar/Grammar:

import_from: ('from' ('.'* dotted_name | '.')

According to Guido's mail:
http://mail.python.org/pipermail/python-dev/2003-December/041065.html
that line should be:

import_from: ('from' ('.'* dotted_name | '.'+)
msg28532 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-05-16 07:25
Logged In: YES 
user_id=849994

Assigned to Thomas. It doesn't seem as simple as adding the
"+" in Grammar.
msg28533 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2006-05-25 11:31
Logged In: YES 
user_id=34209

Actually, it was as simple as adding the '+' to the grammar,
because all the code already expected multiple dots. (My
first few patches actually did this right, but Guido
suggested an alternative (simpler) spelling of the Grammar
rule, and we both forgot the '+' :)

Fixed and testcase added in 46209 and 46210. Thanks!
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43361
2006-05-15 15:26:27zseilcreate