From 5109d50adbba33489ef7fe3fdfaafd7068b5d593 Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Mon, 3 Oct 2016 10:46:24 -0400 Subject: [PATCH] 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. (cherry picked from commit 2addc090501f4ffb5548780ae66e8f0ed9578ce7) --- lib/ansible/plugins/action/synchronize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/plugins/action/synchronize.py b/lib/ansible/plugins/action/synchronize.py index 87e7fdf72e6..b59b8e12e76 100644 --- a/lib/ansible/plugins/action/synchronize.py +++ b/lib/ansible/plugins/action/synchronize.py @@ -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]