Commit 2962073b by Michael DeHaan

Merge branch 'fix-module-encoding' of git://github.com/andreparames/ansible into devel

parents 5c7aa08e 9bb8435e
...@@ -206,7 +206,12 @@ class Runner(object): ...@@ -206,7 +206,12 @@ class Runner(object):
afd, afile = tempfile.mkstemp() afd, afile = tempfile.mkstemp()
afo = os.fdopen(afd, 'w') afo = os.fdopen(afd, 'w')
try: try:
afo.write(data.encode('utf8')) if not isinstance(data, unicode):
#ensure the data is valid UTF-8
data.decode('utf-8')
else:
data = data.encode('utf-8')
afo.write(data)
except: except:
raise errors.AnsibleError("failure encoding into utf-8") raise errors.AnsibleError("failure encoding into utf-8")
afo.flush() afo.flush()
......
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