diff --git a/parso/python/normalizer.py b/parso/python/normalizer.py index 3880966..9afe50b 100644 --- a/parso/python/normalizer.py +++ b/parso/python/normalizer.py @@ -166,6 +166,10 @@ class ErrorFinder(Normalizer): elif name not in ALLOWED_FUTURES: message = "future feature %s is not defined" % name self._add_syntax_error(message, node) + elif node.type == 'import_from': + if node.is_star_import() and self._context.parent_context is not None: + message = "import * only allowed at module level" + self._add_syntax_error(message, node) elif node.type == 'import_as_names': if node.children[-1] == ',': # from foo import a, diff --git a/test/test_python_errors.py b/test/test_python_errors.py index 82031f5..4f428d0 100644 --- a/test/test_python_errors.py +++ b/test/test_python_errors.py @@ -59,6 +59,7 @@ def test_indentation_errors(code, positions): 'code', [ '1 +', '?', + # Python/compile.c dedent('''\ for a in [1]: try: @@ -103,6 +104,7 @@ def test_indentation_errors(code, positions): # SyntaxErrors from Python/symtable.c 'def f(x, x): pass', + 'def x(): from math import *', # IndentationError ' foo',