From 6115f1883769c176a425bce2121f3ae6c38b1c9c Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 7 Jul 2022 22:37:10 +0200 Subject: [PATCH] Fix syntax in `rax_clb_nodes` that breaks in Python3 (#4933) (#4937) * Use syntax that works in both Python 2 and 3 when iterating through a dict that's going to be mutated during iteration * Fixes `dictionary changed size during iteration` error * Fixes #4932 (cherry picked from commit 9a928d5ffb9e08f0f9ba10376058563a7fff8f22) Co-authored-by: Teddy Caddy --- changelogs/fragments/4933-fix-rax-clb-nodes.yaml | 2 ++ plugins/modules/cloud/rackspace/rax_clb_nodes.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/4933-fix-rax-clb-nodes.yaml diff --git a/changelogs/fragments/4933-fix-rax-clb-nodes.yaml b/changelogs/fragments/4933-fix-rax-clb-nodes.yaml new file mode 100644 index 0000000000..8d8c1f2e40 --- /dev/null +++ b/changelogs/fragments/4933-fix-rax-clb-nodes.yaml @@ -0,0 +1,2 @@ +bugfixes: + - rax_clb_nodes - fix code to be compatible with Python 3 (https://github.com/ansible-collections/community.general/pull/4933). diff --git a/plugins/modules/cloud/rackspace/rax_clb_nodes.py b/plugins/modules/cloud/rackspace/rax_clb_nodes.py index 4adcc66fb7..6ed57b53a3 100644 --- a/plugins/modules/cloud/rackspace/rax_clb_nodes.py +++ b/plugins/modules/cloud/rackspace/rax_clb_nodes.py @@ -252,7 +252,8 @@ def main(): 'weight': weight, } - for name, value in mutable.items(): + for name in list(mutable): + value = mutable[name] if value is None or value == getattr(node, name): mutable.pop(name)