diff options
Diffstat (limited to 'kafka/util.py')
-rw-r--r-- | kafka/util.py | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/kafka/util.py b/kafka/util.py index bc01154..de8f228 100644 --- a/kafka/util.py +++ b/kafka/util.py @@ -4,7 +4,6 @@ import atexit import binascii import collections import struct -import sys from threading import Thread, Event import weakref @@ -33,19 +32,6 @@ def write_int_string(s): return struct.pack('>i%ds' % len(s), len(s), s) -def write_short_string(s): - if s is not None and not isinstance(s, six.binary_type): - raise TypeError('Expected "%s" to be bytes\n' - 'data=%s' % (type(s), repr(s))) - if s is None: - return struct.pack('>h', -1) - elif len(s) > 32767 and sys.version_info < (2, 7): - # Python 2.6 issues a deprecation warning instead of a struct error - raise struct.error(len(s)) - else: - return struct.pack('>h%ds' % len(s), len(s), s) - - def read_short_string(data, cur): if len(data) < cur + 2: raise BufferUnderflowError("Not enough data left") @@ -62,24 +48,6 @@ def read_short_string(data, cur): return out, cur + strlen -def read_int_string(data, cur): - if len(data) < cur + 4: - raise BufferUnderflowError( - "Not enough data left to read string len (%d < %d)" % - (len(data), cur + 4)) - - (strlen,) = struct.unpack('>i', data[cur:cur + 4]) - if strlen == -1: - return None, cur + 4 - - cur += 4 - if len(data) < cur + strlen: - raise BufferUnderflowError("Not enough data left") - - out = data[cur:cur + strlen] - return out, cur + strlen - - def relative_unpack(fmt, data, cur): size = struct.calcsize(fmt) if len(data) < cur + size: |