Skip to content

Commit

Permalink
Hotfix: TypeError: object of type 'dict_itemiterator' has no len() (#…
Browse files Browse the repository at this point in the history
…2167)

* Hotfix: TypeError: object of type 'dict_itemiterator' has no len()

* Avoid looping over items 2x

Co-authored-by: Grabowski <chris@crawlinski.com>
  • Loading branch information
indywidualny and Grabowski committed Nov 19, 2020
1 parent c605e0c commit 53dc740
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kafka/protocol/types.py
Expand Up @@ -194,9 +194,10 @@ def __init__(self, *array_of):
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):
Expand Down

0 comments on commit 53dc740

Please sign in to comment.