From 44e6e3a177f72b3c6acd28649ed9f60ac1ecc480 Mon Sep 17 00:00:00 2001 From: dvora-h Date: Tue, 2 May 2023 16:03:40 +0300 Subject: [PATCH] Fix protocol version checking --- 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 71048f548f..288e844a62 100755 --- a/redis/client.py +++ b/redis/client.py @@ -1088,7 +1088,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]