From ccabc2bff57992772cb91ae46bce405580a22c8a Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 22 Oct 2018 20:17:15 -0700 Subject: [PATCH] Revert "[stable-2.7] Handle sets differently than lists in wrap_var. Fixes #47372." This reverts commit 0e933f76ba4edb0e06f0779f5fb4b0ea85191e8b. The tests for this were broken on centos6 because jinja2 does not have a map filter on that platform. Tests need to be rewritten --- changelogs/fragments/unsafe-set-wrap.yaml | 2 -- lib/ansible/utils/unsafe_proxy.py | 8 +------- test/integration/targets/loops/tasks/main.yml | 10 ---------- 3 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 changelogs/fragments/unsafe-set-wrap.yaml diff --git a/changelogs/fragments/unsafe-set-wrap.yaml b/changelogs/fragments/unsafe-set-wrap.yaml deleted file mode 100644 index 5e3a491632..0000000000 --- a/changelogs/fragments/unsafe-set-wrap.yaml +++ /dev/null @@ -1,2 +0,0 @@ -bugfixes: -- unsafe - Add special casing to sets, to support wrapping elements of sets correctly in Python 3 (https://github.com/ansible/ansible/issues/47372) diff --git a/lib/ansible/utils/unsafe_proxy.py b/lib/ansible/utils/unsafe_proxy.py index 2a180e6d4a..a1fce63fa4 100644 --- a/lib/ansible/utils/unsafe_proxy.py +++ b/lib/ansible/utils/unsafe_proxy.py @@ -95,17 +95,11 @@ def _wrap_list(v): return v -def _wrap_set(v): - return set(item if item is None else wrap_var(item) for item in v) - - def wrap_var(v): if isinstance(v, Mapping): v = _wrap_dict(v) - elif isinstance(v, MutableSequence): + elif isinstance(v, (MutableSequence, Set)): v = _wrap_list(v) - elif isinstance(v, Set): - v = _wrap_set(v) elif v is not None and not isinstance(v, AnsibleUnsafe): v = UnsafeProxy(v) return v diff --git a/test/integration/targets/loops/tasks/main.yml b/test/integration/targets/loops/tasks/main.yml index 026d92fd02..8cdd612aaa 100644 --- a/test/integration/targets/loops/tasks/main.yml +++ b/test/integration/targets/loops/tasks/main.yml @@ -258,13 +258,3 @@ loop: [] register: literal_empty_list failed_when: literal_empty_list is not skipped - -# https://github.com/ansible/ansible/issues/47372 -- name: Loop unsafe list - debug: - var: item - with_items: "{{ things|map('string')|unique }}" - vars: - things: - - !unsafe foo - - !unsafe bar