Fix several things causing tracebacks with unicode cwd (#27731)

Fixes #27511
pull/27764/head
Toshio Kuratomi 7 years ago committed by Sam Doran
parent 181b31e282
commit 3f12fccd02

@ -161,7 +161,7 @@ class CLI(with_metaclass(ABCMeta, object)):
running an Ansible command.
"""
display.vv(self.parser.get_version())
display.vv(to_text(self.parser.get_version()))
if C.CONFIG_FILE:
display.v(u"Using %s as config file" % to_text(C.CONFIG_FILE))

@ -35,7 +35,7 @@ __metaclass__ = type
import os
from ansible import constants as C
from ansible.errors import AnsibleParserError
from ansible.module_utils._text import to_bytes, to_text
from ansible.module_utils._text import to_bytes, to_native, to_text
from ansible.plugins.vars import BaseVarsPlugin
from ansible.inventory.host import Host
from ansible.inventory.group import Group
@ -87,7 +87,7 @@ class VarsModule(BaseVarsPlugin):
data = combine_vars(data, new_data)
except Exception as e:
raise AnsibleParserError(to_text(e))
raise AnsibleParserError(to_native(e))
return data
def _find_vars_files(self, path, name):

@ -90,7 +90,7 @@ def stringc(text, color):
if ANSIBLE_COLOR:
color_code = parsecolor(color)
return "\n".join([u"\033[%sm%s\033[0m" % (color_code, t) for t in text.split('\n')])
return u"\n".join([u"\033[%sm%s\033[0m" % (color_code, t) for t in text.split(u'\n')])
else:
return text

@ -75,7 +75,7 @@ def makedirs_safe(path, mode=None):
def basedir(source):
""" returns directory for inventory or playbook """
source = to_bytes(source, errors='surrogate_or_strict')
dname = None
if os.path.isdir(source):
dname = source
@ -88,4 +88,4 @@ def basedir(source):
# don't follow symlinks for basedir, enables source re-use
dname = os.path.abspath(dname)
return dname
return to_text(dname, errors='surrogate_or_strict')

Loading…
Cancel
Save