Fix AST rewriting with starred expressions in function calls
This commit is contained in:
parent
62ca4ae963
commit
195422f9c0
|
@ -775,10 +775,7 @@ class AssertionRewriter(ast.NodeVisitor):
|
||||||
new_kwargs = []
|
new_kwargs = []
|
||||||
for arg in call.args:
|
for arg in call.args:
|
||||||
res, expl = self.visit(arg)
|
res, expl = self.visit(arg)
|
||||||
if type(arg) is ast.Starred:
|
arg_expls.append(expl)
|
||||||
arg_expls.append("*" + expl)
|
|
||||||
else:
|
|
||||||
arg_expls.append(expl)
|
|
||||||
new_args.append(res)
|
new_args.append(res)
|
||||||
for keyword in call.keywords:
|
for keyword in call.keywords:
|
||||||
res, expl = self.visit(keyword.value)
|
res, expl = self.visit(keyword.value)
|
||||||
|
@ -795,6 +792,11 @@ class AssertionRewriter(ast.NodeVisitor):
|
||||||
outer_expl = "%s\n{%s = %s\n}" % (res_expl, res_expl, expl)
|
outer_expl = "%s\n{%s = %s\n}" % (res_expl, res_expl, expl)
|
||||||
return res, outer_expl
|
return res, outer_expl
|
||||||
|
|
||||||
|
def visit_Starred(self, starred):
|
||||||
|
# From Python 3.5, a Starred node can appear in a function call
|
||||||
|
res, expl = self.visit(starred.value)
|
||||||
|
return starred, '*' + expl
|
||||||
|
|
||||||
def visit_Call_legacy(self, call):
|
def visit_Call_legacy(self, call):
|
||||||
"""
|
"""
|
||||||
visit `ast.Call nodes on 3.4 and below`
|
visit `ast.Call nodes on 3.4 and below`
|
||||||
|
|
Loading…
Reference in New Issue