Changes to convert to unicode at the borders

The module docs and vault changes solve issues where tracebacks can
happen.  The galaxy changes are mostly refactoring to be more pythonic
with a small chance that a unicode traceback could have occurred there
without the changes.  The change in __init__.py when we actually call
the pager makes things more robust but could hide places where we had
bytes coming in already so I didn't want to change that without auditing
where the text was coming from.

Fixes #14178
This commit is contained in:
Toshio Kuratomi 2016-01-28 10:50:20 -08:00
commit fa9822df0f
4 changed files with 31 additions and 20 deletions

View file

@ -26,6 +26,7 @@ from ansible.errors import AnsibleError, AnsibleOptionsError
from ansible.parsing.dataloader import DataLoader
from ansible.parsing.vault import VaultEditor
from ansible.cli import CLI
from ansible.utils.unicode import to_unicode
try:
from __main__ import display
@ -157,7 +158,12 @@ class VaultCLI(CLI):
def execute_view(self):
for f in self.args:
self.pager(self.editor.plaintext(f))
# Note: vault should return byte strings because it could encrypt
# and decrypt binary files. We are responsible for changing it to
# unicode here because we are displaying it and therefore can make
# the decision that the display doesn't have to be precisely what
# the input was (leave that to decrypt instead)
self.pager(to_unicode(self.editor.plaintext(f)))
def execute_rekey(self):
for f in self.args: