Skip to content

Commit 53dc740

Browse files
indywidualnyGrabowski
and
Grabowski
authored
Hotfix: TypeError: object of type 'dict_itemiterator' has no len() (dpkp#2167)
* Hotfix: TypeError: object of type 'dict_itemiterator' has no len() * Avoid looping over items 2x Co-authored-by: Grabowski <[email protected]>
1 parent c605e0c commit 53dc740

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kafka/protocol/types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ def __init__(self, *array_of):
194194
def encode(self, items):
195195
if items is None:
196196
return Int32.encode(-1)
197+
encoded_items = [self.array_of.encode(item) for item in items]
197198
return b''.join(
198-
[Int32.encode(len(items))] +
199-
[self.array_of.encode(item) for item in items]
199+
[Int32.encode(len(encoded_items))] +
200+
encoded_items
200201
)
201202

202203
def decode(self, data):

0 commit comments

Comments
 (0)