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: Builtin parser module fails to parse relative imports
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.6, Python 2.5
process
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:

test_parser.py 
--------------
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 "test_parser.py", line 182, in test_relative_import_statement
    self.check_suite("from . import sys")
  File "test_parser.py", line 29, in check_suite
    self.roundtrip(parser.suite, s)
  File "test_parser.py", line 20, in roundtrip
    self.fail("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.
History
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