Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
grumpy
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
grumpy
Commits
c9149b18
Commit
c9149b18
authored
Jan 15, 2017
by
YOU
Committed by
Dylan Trotter
Jan 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise error on wildcard import (#119)
parent
bd4077a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
compiler/stmt.py
compiler/stmt.py
+6
-0
compiler/stmt_test.py
compiler/stmt_test.py
+8
-0
No files found.
compiler/stmt.py
View file @
c9149b18
...
...
@@ -364,6 +364,12 @@ class StatementVisitor(ast.NodeVisitor):
self
.
block
.
bind_var
(
self
.
writer
,
asname
,
mod
.
expr
)
def
visit_ImportFrom
(
self
,
node
):
# Wildcard imports are not yet supported.
for
alias
in
node
.
names
:
if
alias
.
name
==
'*'
:
msg
=
'wildcard member import is not implemented: from %s import %s'
%
(
node
.
module
,
alias
.
name
)
raise
util
.
ParseError
(
node
,
msg
)
self
.
_write_py_context
(
node
.
lineno
)
if
node
.
module
.
startswith
(
_NATIVE_MODULE_PREFIX
):
values
=
[
alias
.
name
for
alias
in
node
.
names
]
...
...
compiler/stmt_test.py
View file @
c9149b18
...
...
@@ -332,6 +332,14 @@ class StatementVisitorTest(unittest.TestCase):
self
.
assertRaisesRegexp
(
util
.
ParseError
,
want_regexp
,
stmt
.
import_from_future
,
node
)
def
testImportWildcardMemberRaises
(
self
):
regexp
=
r'wildcard member import is not implemented: from foo import *'
self
.
assertRaisesRegexp
(
util
.
ParseError
,
regexp
,
_ParseAndVisit
,
'from foo import *'
)
regexp
=
r'wildcard member import is not implemented: from __go__.foo import *'
self
.
assertRaisesRegexp
(
util
.
ParseError
,
regexp
,
_ParseAndVisit
,
'from __go__.foo import *'
)
def
testVisitFuture
(
self
):
testcases
=
[
(
'from __future__ import print_function'
,
...
...
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