From fa669ffd58c587345764f325599b38bfb263353a 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 2c75d4fcf1..3f12b4f8cc 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -922,7 +922,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 57f0a3a81e..711f89fd27 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -930,7 +930,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 = []