summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRavi <ravibhure@gmail.com>2018-03-22 20:59:46 +0100
committerToshio Kuratomi <a.badger@gmail.com>2018-03-29 14:57:54 -0700
commit8c0b91cdb576a8cc9e9c6332aa012d3158a8bf99 (patch)
tree62422508ec57a03e0347a42173e4827ca58c2a6b /lib
parentc40e62d38fd14a3a9ad3bd458722212f0871f00d (diff)
downloadansible-8c0b91cdb576a8cc9e9c6332aa012d3158a8bf99.tar.gz
Fix python3 interpreter issue (#34811) (#35176)
* Fix python3 interpreter issue (#34811) * Update ansible.module_utils._text (#34811) * Convert to text later to account for multibyte characters (cherry picked from commit 340064bfb9678308f3295bf79b82105b972932e1)
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/modules/net_tools/haproxy.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/ansible/modules/net_tools/haproxy.py b/lib/ansible/modules/net_tools/haproxy.py
index 35756f3219..6d5e70c534 100644
--- a/lib/ansible/modules/net_tools/haproxy.py
+++ b/lib/ansible/modules/net_tools/haproxy.py
@@ -202,6 +202,7 @@ import time
from string import Template
from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils._text import to_bytes, to_text
DEFAULT_SOCKET_LOCATION = "/var/run/haproxy.sock"
@@ -251,13 +252,16 @@ class HAProxy(object):
"""
self.client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.client.connect(self.socket)
- self.client.sendall('%s\n' % cmd)
- result = ''
- buf = ''
+ self.client.sendall(to_bytes('%s\n' % cmd))
+
+ result = b''
+ buf = b''
buf = self.client.recv(RECV_SIZE)
while buf:
result += buf
buf = self.client.recv(RECV_SIZE)
+ result = to_text(result, errors='surrogate_or_strict')
+
if capture_output:
self.capture_command_output(cmd, result.strip())
self.client.close()