From ec7019bbe9f9fd604885994a8cf374571c6d66c1 Mon Sep 17 00:00:00 2001 From: Andre Araujo Date: Wed, 15 Nov 2017 13:12:22 -0800 Subject: Fix two bugs in 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`. --- kafka/protocol/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kafka') 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): -- cgit v1.2.1