Note: In v1 we fix this by transforming into unicode just before we use
it (when we send it to jinja2) because jinja2 cannot handle non-ascii
characters in str.

In v2 our model is that all text values need to be stored as unicode
type internally.  So we transform this to unicode when we read it from
the inventory file and save it into the internal dict instead.
This commit is contained in:
Toshio Kuratomi 2015-03-11 21:28:45 -07:00
parent 4710a07fb0
commit ee831e1071

View file

@ -27,6 +27,7 @@ from ansible.inventory.host import Host
from ansible.inventory.group import Group
from ansible.inventory.expand_hosts import detect_range
from ansible.inventory.expand_hosts import expand_hostname_range
from ansible.utils.unicode import to_unicode
class InventoryParser(object):
"""
@ -53,7 +54,7 @@ class InventoryParser(object):
def _parse_value(v):
if "#" not in v:
try:
return ast.literal_eval(v)
v = ast.literal_eval(v)
# Using explicit exceptions.
# Likely a string that literal_eval does not like. We wil then just set it.
except ValueError:
@ -62,7 +63,7 @@ class InventoryParser(object):
except SyntaxError:
# Is this a hash with an equals at the end?
pass
return v
return to_unicode(v, nonstring='passthru', errors='strict')
# [webservers]
# alpha