From ee831e10712c41511b3d7a3d849a99a0e819773e Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 11 Mar 2015 21:28:45 -0700 Subject: [PATCH] Fix v2 for #10426 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. --- v2/ansible/inventory/ini.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/v2/ansible/inventory/ini.py b/v2/ansible/inventory/ini.py index 075701c056c..4236140ac88 100644 --- a/v2/ansible/inventory/ini.py +++ b/v2/ansible/inventory/ini.py @@ -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