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.

Title: Builtin parser module fails to parse relative imports
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.6, Python 2.5
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, schluehk
Priority: normal Keywords:

Created on 2008-12-12 22:50 by schluehk, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg77690 - (view) Author: Kay Schluehr (schluehk) Date: 2008-12-12 22:50
I've added the following test method: 
class RoundtripLegalSyntaxTestCase(unittest.TestCase):

    def test_relative_import_statement(self):
        self.check_suite("from . import sys")

The test fails raising the message:

Traceback (most recent call last):
  File "", line 182, in test_relative_import_statement
    self.check_suite("from . import sys")
  File "", line 29, in check_suite
    self.roundtrip(parser.suite, s)
  File "", line 20, in roundtrip"could not roundtrip %r: %s" % (s, why))
AssertionError: could not roundtrip 'from . import sys': Expected node
type 1, got 23.

Apparently the parser expects a NAME token and gets a DOT token.

This behaviour affects Python 2.5 and Python 2.6. Unchecked for Python 3.0.
msg77707 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-12-13 01:42
This has been fixed in 2.6.1 and will be in 2.5.3.
Date User Action Args
2022-04-11 14:56:42adminsetgithub: 48897
2008-12-13 01:42:38benjamin.petersonsetstatus: open -> closed
resolution: out of date
messages: + msg77707
nosy: + benjamin.peterson
2008-12-12 22:50:21schluehkcreate