Allow Unicode chars to be dumped by yaml stdout callback (#40188)

* Allow Unicode chars to be dumped by yaml stdout callback

Allow Unicode in yaml.dumper to support printing strings unescaped with
\uxxx chars.

Cf. https://stackoverflow.com/a/29600111

* Switch from decode('utf-8') to the more compatible to_text()
pull/40194/merge
Tobias Wolf 7 years ago committed by Toshio Kuratomi
parent 3dd33e7417
commit 25a48fb89e

@ -26,6 +26,8 @@ import string
import sys import sys
from ansible.plugins.callback import CallbackBase, strip_internal_keys from ansible.plugins.callback import CallbackBase, strip_internal_keys
from ansible.plugins.callback.default import CallbackModule as Default from ansible.plugins.callback.default import CallbackModule as Default
from ansible.module_utils.six import string_types
from ansible.module_utils._text import to_bytes, to_text
from ansible.parsing.yaml.dumper import AnsibleDumper from ansible.parsing.yaml.dumper import AnsibleDumper
@ -113,7 +115,7 @@ class CallbackModule(Default):
if abridged_result: if abridged_result:
dumped += '\n' dumped += '\n'
dumped += yaml.dump(abridged_result, width=1000, Dumper=AnsibleDumper, default_flow_style=False) dumped += to_text(yaml.dump(abridged_result, allow_unicode=True, width=1000, Dumper=AnsibleDumper, default_flow_style=False))
# indent by a couple of spaces # indent by a couple of spaces
dumped = '\n '.join(dumped.split('\n')).rstrip() dumped = '\n '.join(dumped.split('\n')).rstrip()

Loading…
Cancel
Save