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
e66c8c7c
Commit
e66c8c7c
authored
Mar 19, 2007
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"from ... import x" should not be a syntax error... make
import_stmt accept ELLIPSes and DOTs.
parent
d16e81aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
Grammar/Grammar
Grammar/Grammar
+2
-1
Python/ast.c
Python/ast.c
+6
-2
No files found.
Grammar/Grammar
View file @
e66c8c7c
...
...
@@ -55,7 +55,8 @@ yield_stmt: yield_expr
raise_stmt: 'raise' [test [',' test [',' test]]]
import_stmt: import_name | import_from
import_name: 'import' dotted_as_names
import_from: ('from' ('.'* dotted_name | '.'+)
# note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
import_from: ('from' (('.' | '...')* dotted_name | ('.' | '...')+)
'import' ('*' | '(' import_as_names ')' | import_as_names))
import_as_name: NAME ['as' NAME]
dotted_as_name: dotted_name ['as' NAME]
...
...
Python/ast.c
View file @
e66c8c7c
...
...
@@ -2406,8 +2406,8 @@ ast_for_import_stmt(struct compiling *c, const node *n)
/*
import_stmt: import_name | import_from
import_name: 'import' dotted_as_names
import_from: 'from' (
'.'* dotted_name | '.') 'import'
('*' | '(' import_as_names ')' | import_as_names)
import_from: 'from' (
('.' | '...')* dotted_name | ('.' | '...')+)
'import'
('*' | '(' import_as_names ')' | import_as_names)
*/
int
lineno
;
int
col_offset
;
...
...
@@ -2445,6 +2445,10 @@ ast_for_import_stmt(struct compiling *c, const node *n)
mod
=
alias_for_import_name
(
c
,
CHILD
(
n
,
idx
));
idx
++
;
break
;
}
else
if
(
TYPE
(
CHILD
(
n
,
idx
))
==
ELLIPSIS
)
{
/* three consecutive dots are tokenized as one ELLIPSIS */
ndots
+=
3
;
continue
;
}
else
if
(
TYPE
(
CHILD
(
n
,
idx
))
!=
DOT
)
{
break
;
}
...
...
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