Commit 90e005d2 by Toshio Kuratomi

Merge pull request #12302 from mgedmin/py3k

Python 3: use the right PyYAML SafeRepresenter for unicode
parents 6de13c30 b95e3d18
...@@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function) ...@@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import yaml import yaml
from six import PY3
from ansible.parsing.yaml.objects import AnsibleUnicode from ansible.parsing.yaml.objects import AnsibleUnicode
...@@ -30,8 +31,13 @@ class AnsibleDumper(yaml.SafeDumper): ...@@ -30,8 +31,13 @@ class AnsibleDumper(yaml.SafeDumper):
''' '''
pass pass
if PY3:
represent_unicode = yaml.representer.SafeRepresenter.represent_str
else:
represent_unicode = yaml.representer.SafeRepresenter.represent_unicode
AnsibleDumper.add_representer( AnsibleDumper.add_representer(
AnsibleUnicode, AnsibleUnicode,
yaml.representer.SafeRepresenter.represent_unicode represent_unicode,
) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment