Normalize how None is handled in quote filter. Fixes #32174 (#71473)

This commit is contained in:
Matt Martz 2020-08-27 14:42:56 -05:00 committed by GitHub
parent addee0699e
commit a1a624b150
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- quote filter - normalize how ``None`` is handled, to match Python3 behavior
(https://github.com/ansible/ansible/issues/32174)

View file

@ -110,6 +110,8 @@ def strftime(string_format, second=None):
def quote(a): def quote(a):
''' return its argument quoted for shell usage ''' ''' return its argument quoted for shell usage '''
if a is None:
a = u''
return shlex_quote(to_text(a)) return shlex_quote(to_text(a))

View file

@ -601,3 +601,10 @@
bar: 123 bar: 123
thing_items: '{{ thing_dict.items() }}' thing_items: '{{ thing_dict.items() }}'
thing_range: '{{ range(10) }}' thing_range: '{{ range(10) }}'
- name: Assert that quote works on None
assert:
that:
- thing|quote == "''"
vars:
thing: null