From 94a9ed0ee1189c0eb59f3fc09e47b2b77aa92970 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 19 Jan 2016 05:48:12 -0800 Subject: [PATCH] Set decoding of path to unicode to raise an exception if non-utf8 Letting it pass would just cause an error later on (no such file found) so it's better to catch it here and know that we have users dealing with non-utf8 pathnames than to have to track it down from later on. --- lib/ansible/inventory/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 0184794fc01..eb8d1905502 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -735,11 +735,11 @@ class Inventory(object): if group and host is None: # load vars in dir/group_vars/name_of_group - base_path = os.path.realpath(os.path.join(to_unicode(basedir), "group_vars/%s" % group.name)) + base_path = os.path.realpath(os.path.join(to_unicode(basedir, errors='strict'), "group_vars/%s" % group.name)) results = combine_vars(results, self._variable_manager.add_group_vars_file(base_path, self._loader)) elif host and group is None: # same for hostvars in dir/host_vars/name_of_host - base_path = os.path.realpath(os.path.join(to_unicode(basedir), "host_vars/%s" % host.name)) + base_path = os.path.realpath(os.path.join(to_unicode(basedir, errors='strict'), "host_vars/%s" % host.name)) results = combine_vars(results, self._variable_manager.add_host_vars_file(base_path, self._loader)) # all done, results is a dictionary of variables for this particular host.