From fb647430f00cc7bb67c978e75f2dabc661567779 Mon Sep 17 00:00:00 2001 From: Shay Fadida Date: Wed, 9 Nov 2022 14:22:27 +0200 Subject: Fix special response parsing options handling (#2302) * Fix special response parsing options handling When using special response parsing options like `NEVER_DECODE` and `EMPTY_RESPONSE`, don't pass them to the response callbacks because some of them are not prepared for receiving named arguments. Instead, redis-py should use them before calling the callbacks and then discard them. * Use kwargs instead of options * change options to kwargs in asyncio/cluster.py/L878 Co-authored-by: Chayim Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com> --- redis/asyncio/client.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'redis/asyncio/client.py') diff --git a/redis/asyncio/client.py b/redis/asyncio/client.py index 6e66faa..619ee11 100644 --- a/redis/asyncio/client.py +++ b/redis/asyncio/client.py @@ -501,12 +501,17 @@ class Redis( try: if NEVER_DECODE in options: response = await connection.read_response(disable_decoding=True) + options.pop(NEVER_DECODE) else: response = await connection.read_response() except ResponseError: if EMPTY_RESPONSE in options: return options[EMPTY_RESPONSE] raise + + if EMPTY_RESPONSE in options: + options.pop(EMPTY_RESPONSE) + if command_name in self.response_callbacks: # Mypy bug: https://github.com/python/mypy/issues/10977 command_name = cast(str, command_name) -- cgit v1.2.1