summaryrefslogtreecommitdiff
path: root/lib/ansible/template/native_helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/template/native_helpers.py')
-rw-r--r--lib/ansible/template/native_helpers.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/ansible/template/native_helpers.py b/lib/ansible/template/native_helpers.py
index c56d0d217f..11c14b7fa1 100644
--- a/lib/ansible/template/native_helpers.py
+++ b/lib/ansible/template/native_helpers.py
@@ -13,9 +13,6 @@ import types
from jinja2._compat import text_type
from jinja2.runtime import StrictUndefined
-
-from ansible.module_utils.common.text.converters import container_to_text
-from ansible.module_utils.six import PY2
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode
@@ -51,6 +48,10 @@ def ansible_native_concat(nodes):
# See https://github.com/ansible/ansible/issues/52158
# We do that only here because it is taken care of by text_type() in the else block below already.
str(out)
+
+ # short circuit literal_eval when possible
+ if not isinstance(out, list):
+ return out
else:
if isinstance(nodes, types.GeneratorType):
nodes = chain(head, nodes)
@@ -59,10 +60,6 @@ def ansible_native_concat(nodes):
out = u''.join([text_type(v) for v in nodes])
try:
- out = literal_eval(out)
- if PY2:
- # ensure bytes are not returned back into Ansible from templating
- out = container_to_text(out)
- return out
+ return literal_eval(out)
except (ValueError, SyntaxError, MemoryError):
return out