diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py index 862f6f096b..e77fba30da 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -925,7 +925,8 @@ def pack_commands(self, commands: Iterable[Iterable[EncodableT]]) -> List[bytes] or chunklen > buffer_cutoff or isinstance(chunk, memoryview) ): - output.append(SYM_EMPTY.join(pieces)) + if pieces: + output.append(SYM_EMPTY.join(pieces)) buffer_length = 0 pieces = [] diff --git a/redis/connection.py b/redis/connection.py index b2f34293a5..24614824c5 100644 --- a/redis/connection.py +++ b/redis/connection.py @@ -976,7 +976,8 @@ def pack_commands(self, commands): or chunklen > buffer_cutoff or isinstance(chunk, memoryview) ): - output.append(SYM_EMPTY.join(pieces)) + if pieces: + output.append(SYM_EMPTY.join(pieces)) buffer_length = 0 pieces = []