Skip to content

Commit

Permalink
Ensure --version works with non-ascii paths
Browse files Browse the repository at this point in the history
Fixes #66617
  • Loading branch information
mkrizek committed Jan 20, 2020
1 parent 3bf8b1d commit 706528c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/66617-version-unicode-fix.yml
@@ -0,0 +1,2 @@
bugfixes:
- Ensure that ``--version`` works with non-ascii paths (https://github.com/ansible/ansible/issues/66617)
21 changes: 11 additions & 10 deletions lib/ansible/cli/arguments/option_helpers.py
Expand Up @@ -15,7 +15,7 @@

import ansible
from ansible import constants as C
from ansible.module_utils._text import to_native
from ansible.module_utils._text import to_native, to_text
from ansible.release import __version__
from ansible.utils.path import unfrackpath

Expand Down Expand Up @@ -164,22 +164,23 @@ def _gitinfo():
def version(prog=None):
""" return ansible version """
if prog:
result = " ".join((prog, __version__))
result = u" ".join((prog, __version__))
else:
result = __version__

gitinfo = _gitinfo()
if gitinfo:
result = result + " {0}".format(gitinfo)
result += "\n config file = %s" % C.CONFIG_FILE
result = result + u" {0}".format(gitinfo)
result += u"\n config file = %s" % to_text(C.CONFIG_FILE)
if C.DEFAULT_MODULE_PATH is None:
cpath = "Default w/o overrides"
cpath = u"Default w/o overrides"
else:
cpath = C.DEFAULT_MODULE_PATH
result = result + "\n configured module search path = %s" % cpath
result = result + "\n ansible python module location = %s" % ':'.join(ansible.__path__)
result = result + "\n executable location = %s" % sys.argv[0]
result = result + "\n python version = %s" % ''.join(sys.version.splitlines())
cpath = u", ".join(C.DEFAULT_MODULE_PATH)
python_module_location = u":".join(map(to_text, ansible.__path__))
result = result + u"\n configured module search path = %s" % cpath
result = result + u"\n ansible python module location = %s" % python_module_location
result = result + u"\n executable location = %s" % to_text(sys.argv[0])
result = result + u"\n python version = %s" % ''.join(sys.version.splitlines())
return result


Expand Down

0 comments on commit 706528c

Please sign in to comment.