From 49ed60b2cd57dee3ae0bd9667ebff1bbbb377ac5 Mon Sep 17 00:00:00 2001 From: dvora-h <67596500+dvora-h@users.noreply.github.com> Date: Thu, 4 May 2023 12:02:50 +0300 Subject: [PATCH] Fix protocol version checking (#2737) --- redis/asyncio/client.py | 2 +- redis/client.py | 2 +- tests/conftest.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/redis/asyncio/client.py b/redis/asyncio/client.py index 5ef1f3292e..2cd2daddcc 100644 --- a/redis/asyncio/client.py +++ b/redis/asyncio/client.py @@ -255,7 +255,7 @@ def __init__( self.response_callbacks = CaseInsensitiveDict(self.__class__.RESPONSE_CALLBACKS) - if self.connection_pool.connection_kwargs.get("protocol") == "3": + if self.connection_pool.connection_kwargs.get("protocol") in ["3", 3]: self.response_callbacks.update(self.__class__.RESP3_RESPONSE_CALLBACKS) # If using a single connection client, we need to lock creation-of and use-of diff --git a/redis/client.py b/redis/client.py index 565f133d6f..c303dbde38 100755 --- a/redis/client.py +++ b/redis/client.py @@ -1109,7 +1109,7 @@ def __init__( self.response_callbacks = CaseInsensitiveDict(self.__class__.RESPONSE_CALLBACKS) - if self.connection_pool.connection_kwargs.get("protocol") == "3": + if self.connection_pool.connection_kwargs.get("protocol") in ["3", 3]: self.response_callbacks.update(self.__class__.RESP3_RESPONSE_CALLBACKS) def __repr__(self): diff --git a/tests/conftest.py b/tests/conftest.py index 035dbc85cf..c471f3d837 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -479,4 +479,4 @@ def is_resp2_connection(r): protocol = r.connection_pool.connection_kwargs.get("protocol") elif isinstance(r, redis.RedisCluster): protocol = r.nodes_manager.connection_kwargs.get("protocol") - return protocol == "2" or protocol is None + return protocol in ["2", 2, None]