When outputting text to a file, convert to bytes first.

Fixes #23137
This commit is contained in:
Toshio Kuratomi 2017-03-30 08:31:09 -07:00 committed by Brian Coca
parent 2e476e64cd
commit 0249918c7b

View file

@ -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)