From 915b00dab79626305a45d14cbcf5f3b125fb0a49 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sun, 23 Jul 2017 23:22:05 +0200 Subject: [PATCH] Added issue: iterable unpacking cannot be used in comprehension --- parso/python/normalizer.py | 4 ++++ test/test_python_errors.py | 1 + 2 files changed, 5 insertions(+) diff --git a/parso/python/normalizer.py b/parso/python/normalizer.py index 523252a..d7c6822 100644 --- a/parso/python/normalizer.py +++ b/parso/python/normalizer.py @@ -136,6 +136,10 @@ class ErrorFinder(Normalizer): if node.parent.type not in _STAR_EXPR_PARENTS: message = "starred assignment target must be in a list or tuple" self._add_syntax_error(message, node) + if node.parent.type == 'testlist_comp': + # [*[] for a in [1]] + message = "iterable unpacking cannot be used in comprehension" + self._add_syntax_error(message, node) elif node.type == 'comp_for': if node.children[0] == 'async' \ and not self._context.is_async_funcdef(): diff --git a/test/test_python_errors.py b/test/test_python_errors.py index 3b60070..887bda3 100644 --- a/test/test_python_errors.py +++ b/test/test_python_errors.py @@ -109,6 +109,7 @@ def test_python_exception_matches(code): ('del *a, b', '3.5'), ('def x(*): pass', '3.5'), ('async def foo():\n def nofoo():[x async for x in []]', '3.6'), + ('[*[] for a in [1]]', '3.5'), ] ) def test_python_exception_matches_version(code, version):