]> granicus.if.org Git - python/commitdiff
Merged revisions 67077 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Mon, 3 Nov 2008 15:18:30 +0000 (15:18 +0000)
committerBenjamin Peterson <benjamin@python.org>
Mon, 3 Nov 2008 15:18:30 +0000 (15:18 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r67077 | benjamin.peterson | 2008-11-03 09:14:51 -0600 (Mon, 03 Nov 2008) | 1 line

  #4048 make the parser module accept relative imports as valid
........

Lib/test/test_parser.py
Misc/ACKS
Misc/NEWS
Modules/parsermodule.c

index 9ecca51a36060e7ba729ee3130190e6e9c8b37c4..94b6113a0c3b03df513ca43cabebfd95f56c85b8 100644 (file)
@@ -1,4 +1,5 @@
 import parser
+import os
 import unittest
 import sys
 from test import test_support
@@ -179,6 +180,7 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
             "from sys.path import (dirname, basename as my_basename)")
         self.check_suite(
             "from sys.path import (dirname, basename as my_basename,)")
+        self.check_suite("from .bogus import x")
 
     def test_basic_import_statement(self):
         self.check_suite("import sys")
index ac8f6edd434914e54c61f36bccdff205d0ca4ec9..72b18c9c5145ec314a582228206291a8e10ab0f6 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -62,6 +62,7 @@ Eric Beser
 Steven Bethard
 Stephen Bevan
 Ron Bickers
+David Binger
 Dominic Binks
 Philippe Biondi
 Stuart Bishop
index c47620a936868216cbb0fcaa49adfbfb91c4b306..bb083a255dd6047901d405781f9f2d0bb9d1c48b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.6.1 alpha 1
 Core and Builtins
 -----------------
 
+- Issue #4048: The parser module now correctly validates relative imports.
+
 - Issue #4225: ``from __future__ import unicode_literals`` didn't work in an
   exec statement.
 
index 423a0b350062daeab95dbdac187bc2bc241e9e5c..bea78c2ce129bf09215380e78faa463896648844 100644 (file)
@@ -1879,10 +1879,10 @@ static int
 count_from_dots(node *tree)
 {
         int i;
-        for (i = 0; i < NCH(tree); i++)
+        for (i = 1; i < NCH(tree); i++)
                if (TYPE(CHILD(tree, i)) != DOT)
                        break;
-        return i;
+        return i-1;
 }
 
 /* 'from' ('.'* dotted_name | '.') 'import' ('*' | '(' import_as_names ')' |