summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Araujo <araujo@cloudera.com>2017-11-15 13:12:22 -0800
committerJeff Widman <jeff@jeffwidman.com>2017-11-15 13:16:59 -0800
commitec7019bbe9f9fd604885994a8cf374571c6d66c1 (patch)
tree0258ec75616ad1316a70d89813bd6123fc0f5137
parenta3995b38210d3700855d5b438529a5387c095569 (diff)
downloadkafka-python-fix-minor-bug-with-printing-bytes-instance.tar.gz
Fix two bugs in printing bytes instancefix-minor-bug-with-printing-bytes-instance
Bug 1: When `value` is None, trying to call `len(None)` throws an exception. Bug 2: When len(`value`) <= 100, the code currently prints b'' rather than `value`.
-rw-r--r--kafka/protocol/types.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/kafka/protocol/types.py b/kafka/protocol/types.py
index c95bd6d..22b49a4 100644
--- a/kafka/protocol/types.py
+++ b/kafka/protocol/types.py
@@ -100,7 +100,7 @@ class Bytes(AbstractType):
@classmethod
def repr(cls, value):
- return repr(value[:100] + b'...' if len(value) > 100 else b'')
+ return repr(value[:100] + b'...' if value is not None and len(value) > 100 else value)
class Boolean(AbstractType):