cast/copy keys() to list to avoid py3 errors

In py3, dict.keys() is a view and not a copy of the
dicts keys, so attempting to delete items from the dict
while iterating over the keys results int

RuntimeError: dictionary changed size during iteration

Resolve by casting .keys() to a list() type.
pull/17888/head
Adrian Likins 8 years ago committed by Toshio Kuratomi
parent 9f673e0725
commit 2addc09050

@ -114,7 +114,7 @@ class ActionModule(ActionBase):
# connection to the remote host
if 'ansible_syslog_facility' in task_vars:
del task_vars['ansible_syslog_facility']
for key in task_vars.keys():
for key in list(task_vars.keys()):
if key.startswith("ansible_") and key.endswith("_interpreter"):
del task_vars[key]

Loading…
Cancel
Save