From 7fbaf3aa4a416031045d5698ad79f1a79eee6813 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 23 Sep 2015 14:13:46 -0700 Subject: [PATCH] Fixes #12488 --- lib/ansible/utils/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index ff697ff871d..8120fbc1398 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -229,9 +229,9 @@ def write_tree_file(tree, hostname, buf): # TODO: might be nice to append playbook runs per host in a similar way # in which case, we'd want append mode. path = os.path.join(tree, hostname) - fd = open(path, "w+") - fd.write(buf) - fd.close() + buf = to_bytes(buf) + with open(path, 'wb+') as fd: + fd.write(buf) def is_failed(result): ''' is a given JSON result a failed result? '''