backport r67077 from the trunk: parser module now correctly validates relative imports
This commit is contained in:
parent
3b335ff340
commit
6f08e85ad9
|
@ -1,4 +1,5 @@
|
||||||
import parser
|
import parser
|
||||||
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from test import test_support
|
from test import test_support
|
||||||
|
|
||||||
|
@ -168,6 +169,7 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
|
||||||
"from sys.path import (dirname, basename as my_basename)")
|
"from sys.path import (dirname, basename as my_basename)")
|
||||||
self.check_suite(
|
self.check_suite(
|
||||||
"from sys.path import (dirname, basename as my_basename,)")
|
"from sys.path import (dirname, basename as my_basename,)")
|
||||||
|
self.check_suite("from .bogus import x")
|
||||||
|
|
||||||
def test_basic_import_statement(self):
|
def test_basic_import_statement(self):
|
||||||
self.check_suite("import sys")
|
self.check_suite("import sys")
|
||||||
|
|
|
@ -60,6 +60,7 @@ Eric Beser
|
||||||
Steven Bethard
|
Steven Bethard
|
||||||
Stephen Bevan
|
Stephen Bevan
|
||||||
Ron Bickers
|
Ron Bickers
|
||||||
|
David Binger
|
||||||
Dominic Binks
|
Dominic Binks
|
||||||
Philippe Biondi
|
Philippe Biondi
|
||||||
Stuart Bishop
|
Stuart Bishop
|
||||||
|
|
|
@ -12,6 +12,8 @@ What's New in Python 2.5.3?
|
||||||
Core and builtins
|
Core and builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #4048: The parser module now correctly validates relative imports.
|
||||||
|
|
||||||
- Issue #4176: Fixed a crash when pickling an object which ``__reduce__``
|
- Issue #4176: Fixed a crash when pickling an object which ``__reduce__``
|
||||||
method does not return iterators for the 4th and 5th items.
|
method does not return iterators for the 4th and 5th items.
|
||||||
|
|
||||||
|
|
|
@ -1804,10 +1804,10 @@ static int
|
||||||
count_from_dots(node *tree)
|
count_from_dots(node *tree)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < NCH(tree); i++)
|
for (i = 1; i < NCH(tree); i++)
|
||||||
if (TYPE(CHILD(tree, i)) != DOT)
|
if (TYPE(CHILD(tree, i)) != DOT)
|
||||||
break;
|
break;
|
||||||
return i;
|
return i-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 'from' ('.'* dotted_name | '.') 'import' ('*' | '(' import_as_names ')' |
|
/* 'from' ('.'* dotted_name | '.') 'import' ('*' | '(' import_as_names ')' |
|
||||||
|
|
Loading…
Reference in New Issue