Handle UTF-8 in templates

This is required to run commands containing non-ASCII characters, e.g.:

ansible localhost -m shell -a 'echo ą'
This commit is contained in:
Grzegorz Nosek 2012-08-20 21:00:31 +02:00 committed by Michael DeHaan
parent 4121109665
commit 2aef0335cb

View file

@ -215,6 +215,10 @@ def template(text, vars):
''' run a text buffer through the templating engine until it no longer changes '''
prev_text = ''
try:
text = text.decode('utf-8')
except UnicodeEncodeError:
pass # already unicode
depth = 0
while prev_text != text:
depth = depth + 1