summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Grabowski <koras@indywidualni.org>2020-11-19 22:51:14 +0100
committerGitHub <noreply@github.com>2020-11-19 13:51:14 -0800
commit53dc740bce8ef19c32fad2881021d1f6bb055f7a (patch)
tree3926e6e133f9bf7c6dffc17190c388a36c22f6da
parentc605e0cab4ff87710238d3d3ed74b3938e919799 (diff)
downloadkafka-python-53dc740bce8ef19c32fad2881021d1f6bb055f7a.tar.gz
Hotfix: TypeError: object of type 'dict_itemiterator' has no len() (#2167)
* Hotfix: TypeError: object of type 'dict_itemiterator' has no len() * Avoid looping over items 2x Co-authored-by: Grabowski <chris@crawlinski.com>
-rw-r--r--kafka/protocol/types.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/kafka/protocol/types.py b/kafka/protocol/types.py
index ade1bc6..2fde24f 100644
--- a/kafka/protocol/types.py
+++ b/kafka/protocol/types.py
@@ -194,9 +194,10 @@ class Array(AbstractType):
def encode(self, items):
if items is None:
return Int32.encode(-1)
+ encoded_items = [self.array_of.encode(item) for item in items]
return b''.join(
- [Int32.encode(len(items))] +
- [self.array_of.encode(item) for item in items]
+ [Int32.encode(len(encoded_items))] +
+ encoded_items
)
def decode(self, data):