From 25a48fb89ed3baf7a474ea3fccb7777603d4ffca Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Wed, 16 May 2018 00:23:13 +0200 Subject: [PATCH] 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() --- lib/ansible/plugins/callback/yaml.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/callback/yaml.py b/lib/ansible/plugins/callback/yaml.py index 971193a237..50d334a5a9 100644 --- a/lib/ansible/plugins/callback/yaml.py +++ b/lib/ansible/plugins/callback/yaml.py @@ -26,6 +26,8 @@ import string import sys from ansible.plugins.callback import CallbackBase, strip_internal_keys 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 @@ -113,7 +115,7 @@ class CallbackModule(Default): if abridged_result: 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 dumped = '\n '.join(dumped.split('\n')).rstrip()