[Python-checkins] r67079 - in python/branches/release25-maint: Lib/test/test_parser.py Misc/ACKS Misc/NEWS Modules/parsermodule.c

benjamin.peterson python-checkins at python.org
Mon Nov 3 16:19:35 CET 2008


Author: benjamin.peterson
Date: Mon Nov  3 16:19:35 2008
New Revision: 67079

Log:
backport r67077 from the trunk: parser module now correctly validates relative imports

Modified:
   python/branches/release25-maint/Lib/test/test_parser.py
   python/branches/release25-maint/Misc/ACKS
   python/branches/release25-maint/Misc/NEWS
   python/branches/release25-maint/Modules/parsermodule.c

Modified: python/branches/release25-maint/Lib/test/test_parser.py
==============================================================================
--- python/branches/release25-maint/Lib/test/test_parser.py	(original)
+++ python/branches/release25-maint/Lib/test/test_parser.py	Mon Nov  3 16:19:35 2008
@@ -1,4 +1,5 @@
 import parser
+import os
 import unittest
 from test import test_support
 
@@ -168,6 +169,7 @@
             "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")

Modified: python/branches/release25-maint/Misc/ACKS
==============================================================================
--- python/branches/release25-maint/Misc/ACKS	(original)
+++ python/branches/release25-maint/Misc/ACKS	Mon Nov  3 16:19:35 2008
@@ -60,6 +60,7 @@
 Steven Bethard
 Stephen Bevan
 Ron Bickers
+David Binger
 Dominic Binks
 Philippe Biondi
 Stuart Bishop

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Mon Nov  3 16:19:35 2008
@@ -12,6 +12,8 @@
 Core and builtins
 -----------------
 
+- Issue #4048: The parser module now correctly validates relative imports.
+
 - Issue #4176: Fixed a crash when pickling an object which ``__reduce__``
   method does not return iterators for the 4th and 5th items.
 

Modified: python/branches/release25-maint/Modules/parsermodule.c
==============================================================================
--- python/branches/release25-maint/Modules/parsermodule.c	(original)
+++ python/branches/release25-maint/Modules/parsermodule.c	Mon Nov  3 16:19:35 2008
@@ -1804,10 +1804,10 @@
 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 ')' |


More information about the Python-checkins mailing list