diff options
Diffstat (limited to 'kafka/util.py')
-rw-r--r-- | kafka/util.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kafka/util.py b/kafka/util.py index 09a5bbb..9121374 100644 --- a/kafka/util.py +++ b/kafka/util.py @@ -7,6 +7,9 @@ from kafka.common import BufferUnderflowError def write_int_string(s): + if s is not None and not isinstance(s, str): + raise TypeError('Expected "%s" to be str\n' + 'data=%s' % (type(s), repr(s))) if s is None: return struct.pack('>i', -1) else: @@ -14,6 +17,9 @@ def write_int_string(s): def write_short_string(s): + if s is not None and not isinstance(s, str): + raise TypeError('Expected "%s" to be str\n' + 'data=%s' % (type(s), repr(s))) if s is None: return struct.pack('>h', -1) elif len(s) > 32767 and sys.version < (2, 7): |