summaryrefslogtreecommitdiff
path: root/kafka/conn.py
diff options
context:
space:
mode:
authorBruno ReniƩ <brutasse@gmail.com>2014-08-28 20:50:20 +0200
committerMark Roberts <wizzat@fb.com>2014-09-03 09:55:44 -0700
commitcf0b7f0530e765f2cf710bd35daf53bb4ea205d2 (patch)
treef38669f145112a7f301691f311b3c8aca51d1f59 /kafka/conn.py
parent83af5102e995e854a1980b90f1400afdd098da37 (diff)
downloadkafka-python-cf0b7f0530e765f2cf710bd35daf53bb4ea205d2.tar.gz
Make all unit tests pass on py3.3/3.4
Diffstat (limited to 'kafka/conn.py')
-rw-r--r--kafka/conn.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/kafka/conn.py b/kafka/conn.py
index a1b0a80..41cd424 100644
--- a/kafka/conn.py
+++ b/kafka/conn.py
@@ -5,6 +5,8 @@ import struct
from random import shuffle
from threading import local
+import six
+
from kafka.common import ConnectionError
log = logging.getLogger("kafka")
@@ -19,7 +21,7 @@ def collect_hosts(hosts, randomize=True):
randomize the returned list.
"""
- if isinstance(hosts, basestring):
+ if isinstance(hosts, six.string_types):
hosts = hosts.strip().split(',')
result = []
@@ -92,7 +94,7 @@ class KafkaConnection(local):
# Receiving empty string from recv signals
# that the socket is in error. we will never get
# more data from this socket
- if data == '':
+ if data == b'':
raise socket.error("Not enough data to read message -- did server kill socket?")
except socket.error:
@@ -103,7 +105,7 @@ class KafkaConnection(local):
log.debug("Read %d/%d bytes from Kafka", num_bytes - bytes_left, num_bytes)
responses.append(data)
- return ''.join(responses)
+ return b''.join(responses)
##################
# Public API #
@@ -144,7 +146,7 @@ class KafkaConnection(local):
# Read the remainder of the response
resp = self._read_bytes(size)
- return str(resp)
+ return resp
def copy(self):
"""