From c34f85c788a9ba2a770f36aae9452a901b4c701d Mon Sep 17 00:00:00 2001 From: Mattias Lindvall Date: Mon, 28 Jan 2019 17:34:39 +0100 Subject: [PATCH] Python3 fix: Decode output from popen in iocage connection (#41868) * decode output from popen in iocage connection * use ansibles to_native instead of stdlibs decode --- lib/ansible/plugins/connection/iocage.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/connection/iocage.py b/lib/ansible/plugins/connection/iocage.py index a7bd85d4ff4..23018c7bc26 100644 --- a/lib/ansible/plugins/connection/iocage.py +++ b/lib/ansible/plugins/connection/iocage.py @@ -32,8 +32,9 @@ DOCUMENTATION = """ """ import subprocess -from ansible.plugins.connection.jail import Connection as Jail +from ansible.plugins.connection.jail import Connection as Jail +from ansible.module_utils._text import to_native from ansible.errors import AnsibleError from ansible.utils.display import Display @@ -67,6 +68,13 @@ class Connection(Jail): stderr=subprocess.STDOUT) stdout, stderr = p.communicate() + + if stdout is not None: + stdout = to_native(stdout) + + if stderr is not None: + stderr = to_native(stderr) + # otherwise p.returncode would not be set p.wait()