From c16d258a27d73a31a577f02fdcbcdadd78fb2d95 Mon Sep 17 00:00:00 2001 From: Sergey Scherbakov Date: Thu, 31 Aug 2017 10:39:24 +0300 Subject: [PATCH] Fix encoding error on grp.gr_name, which can contain non-ascii chars at domain PCs (#25804) * Fix encoding errors on grp.gr_name, which can contain non-ascii character at LDAP/AD domain workstations * fix: utils.to_text() is now used instead of py3-incompatible unicode() method --- lib/ansible/plugins/lookup/filetree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/plugins/lookup/filetree.py b/lib/ansible/plugins/lookup/filetree.py index 762cf24d677..68615f6a04b 100644 --- a/lib/ansible/plugins/lookup/filetree.py +++ b/lib/ansible/plugins/lookup/filetree.py @@ -30,7 +30,7 @@ except ImportError: pass from ansible.plugins.lookup import LookupBase -from ansible.module_utils._text import to_native +from ansible.module_utils._text import to_native, to_text try: from __main__ import display @@ -87,7 +87,7 @@ def file_props(root, path): except KeyError: ret['owner'] = st.st_uid try: - ret['group'] = grp.getgrgid(st.st_gid).gr_name + ret['group'] = to_text(grp.getgrgid(st.st_gid).gr_name) except KeyError: ret['group'] = st.st_gid ret['mode'] = '0%03o' % (stat.S_IMODE(st.st_mode))