if isinstance(ast, (Lambda, Function)):
# Formal parameters of the function are excluded from
# captures we care about in subnodes of the function body.
- assigned = assigned.copy()
- for argname in ast.argnames:
- if argname in assigned:
- del assigned[argname]
+ new_assigned = assigned.copy()
+ remove_argnames(ast.argnames, new_assigned)
if len(new_assigned) > 0:
for child in childnodes[len(ast.defaults):]:
collect_captured(child, assigned, captured, True)
+def remove_argnames(names, fromset):
+ for element in names:
+ if element in fromset:
+ del fromset[element]
+ elif isinstance(element, (tuple, list)):
+ remove_argnames(element, fromset)
+
+
def make_result(funcnode, var_name, var_lineno):
if hasattr(funcnode, 'name'):
func_name = 'function %r' % (funcnode.name,)