[pypy-commit] pypy py3.5: Throw error if unpacking is used in comprehension
raffael_t
pypy.commits at gmail.com
Wed Jun 22 12:24:25 EDT 2016
Author: Raffael Tfirst <raffael.tfirst at gmail.com>
Branch: py3.5
Changeset: r85331:3c7f568374d8
Date: 2016-06-22 18:23 +0200
http://bitbucket.org/pypy/pypy/changeset/3c7f568374d8/
Log: Throw error if unpacking is used in comprehension
diff --git a/pypy/interpreter/astcompiler/astbuilder.py b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -1315,18 +1315,24 @@
def handle_genexp(self, genexp_node):
elt = self.handle_expr(genexp_node.get_child(0))
+ if elt.type == syms.star_expr:
+ self.error("iterable unpacking cannot be used in comprehension", elt)
comps = self.comprehension_helper(genexp_node.get_child(1))
return ast.GeneratorExp(elt, comps, genexp_node.get_lineno(),
genexp_node.get_column())
def handle_listcomp(self, listcomp_node):
elt = self.handle_expr(listcomp_node.get_child(0))
+ if elt.type == syms.star_expr:
+ self.error("iterable unpacking cannot be used in comprehension", elt)
comps = self.comprehension_helper(listcomp_node.get_child(1))
return ast.ListComp(elt, comps, listcomp_node.get_lineno(),
listcomp_node.get_column())
def handle_setcomp(self, set_maker):
elt = self.handle_expr(set_maker.get_child(0))
+ if elt.type == syms.star_expr:
+ self.error("iterable unpacking cannot be used in comprehension", elt)
comps = self.comprehension_helper(set_maker.get_child(1))
return ast.SetComp(elt, comps, set_maker.get_lineno(),
set_maker.get_column())
More information about the pypy-commit
mailing list