Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
fb48afa7
Commit
fb48afa7
authored
Jul 08, 2006
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SF bug #1519018: 'as' is now validated properly in import statements
parent
b6b17522
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
Lib/test/test_compile.py
Lib/test/test_compile.py
+4
-0
Misc/NEWS
Misc/NEWS
+2
-0
Python/ast.c
Python/ast.c
+12
-1
No files found.
Lib/test/test_compile.py
View file @
fb48afa7
...
...
@@ -238,6 +238,8 @@ if 1:
succeed
=
[
'import sys'
,
'import os, sys'
,
'import os as bar'
,
'import os.path as bar'
,
'from __future__ import nested_scopes, generators'
,
'from __future__ import (nested_scopes,
\
n
generators)'
,
'from __future__ import (nested_scopes,
\
n
generators,)'
,
...
...
@@ -257,6 +259,8 @@ if 1:
'import (sys'
,
'import sys)'
,
'import (os,)'
,
'import os As bar'
,
'import os.path a bar'
,
'from (sys) import stdin'
,
'from __future__ import (nested_scopes'
,
'from __future__ import nested_scopes)'
,
...
...
Misc/NEWS
View file @
fb48afa7
...
...
@@ -22,6 +22,8 @@ Core and builtins
omit a default "error" argument for NULL pointer. This allows
the parser to take a codec from cjkcodecs again.
- Bug #1519018: '
as
' is now validated properly in import statements.
Library
-------
...
...
Python/ast.c
View file @
fb48afa7
...
...
@@ -2142,7 +2142,14 @@ alias_for_import_name(struct compiling *c, const node *n)
loop:
switch
(
TYPE
(
n
))
{
case
import_as_name
:
str
=
(
NCH
(
n
)
==
3
)
?
NEW_IDENTIFIER
(
CHILD
(
n
,
2
))
:
NULL
;
str
=
NULL
;
if
(
NCH
(
n
)
==
3
)
{
if
(
strcmp
(
STR
(
CHILD
(
n
,
1
)),
"as"
)
!=
0
)
{
ast_error
(
n
,
"must use 'as' in import"
);
return
NULL
;
}
str
=
NEW_IDENTIFIER
(
CHILD
(
n
,
2
));
}
return
alias
(
NEW_IDENTIFIER
(
CHILD
(
n
,
0
)),
str
,
c
->
c_arena
);
case
dotted_as_name
:
if
(
NCH
(
n
)
==
1
)
{
...
...
@@ -2151,6 +2158,10 @@ alias_for_import_name(struct compiling *c, const node *n)
}
else
{
alias_ty
a
=
alias_for_import_name
(
c
,
CHILD
(
n
,
0
));
if
(
strcmp
(
STR
(
CHILD
(
n
,
1
)),
"as"
)
!=
0
)
{
ast_error
(
n
,
"must use 'as' in import"
);
return
NULL
;
}
assert
(
!
a
->
asname
);
a
->
asname
=
NEW_IDENTIFIER
(
CHILD
(
n
,
2
));
return
a
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment