From 0249918c7b69d021d8a17c9ca263a111403c74f7 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 30 Mar 2017 08:31:09 -0700 Subject: [PATCH] When outputting text to a file, convert to bytes first. Fixes #23137 --- docs/bin/generate_man.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/bin/generate_man.py b/docs/bin/generate_man.py index d231b46232..f3615f63a0 100755 --- a/docs/bin/generate_man.py +++ b/docs/bin/generate_man.py @@ -1,11 +1,12 @@ #!/usr/bin/env python import os -import io import sys from jinja2 import Environment, FileSystemLoader +from ansible.module_utils._text import to_bytes + def get_options(optlist): ''' get actual options ''' @@ -124,6 +125,6 @@ if __name__ == '__main__': manpage = template.render(tvars) filename = '../man/man1/%s' % output[libname] - with io.open(filename, 'w') as f: - f.write(manpage) + with open(filename, 'wb') as f: + f.write(to_bytes(manpage)) print("Wrote man docs to %s" % filename)