From c9dfad36d71ca91adcffea94ae09725ffd55e93f Mon Sep 17 00:00:00 2001 From: James Bailey Date: Thu, 13 Oct 2022 17:29:01 +0100 Subject: [PATCH] Fix issue with `pack_commands` returning an empty byte sequence --- redis/asyncio/connection.py | 3 ++- redis/connection.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py index c8834c9286..249507d24e 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -975,7 +975,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 2e33e31d2f..964ae135fb 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -875,7 +875,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 = []