jinja2_native: short-circuit literal_eval for non-strings (#75484)

pull/75501/head
Martin Krizek 3 years ago committed by GitHub
parent 351f122e24
commit 3ecf438e66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
minor_changes:
- jinja2_native - short-circuit ``ast.literal_eval`` for non-string values

@ -15,7 +15,7 @@ from jinja2.runtime import StrictUndefined
from ansible.module_utils._text import to_text
from ansible.module_utils.common.collections import is_sequence, Mapping
from ansible.module_utils.common.text.converters import container_to_text
from ansible.module_utils.six import PY2, text_type
from ansible.module_utils.six import PY2, text_type, string_types
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode
from ansible.utils.native_jinja import NativeJinjaText
@ -73,6 +73,10 @@ def ansible_native_concat(nodes):
# https://github.com/pallets/jinja/issues/1200
# https://github.com/ansible/ansible/issues/70831#issuecomment-664190894
return out
# short-circuit literal_eval for anything other than strings
if not isinstance(out, string_types):
return out
else:
if isinstance(nodes, types.GeneratorType):
nodes = chain(head, nodes)

Loading…
Cancel
Save