Skip to content

Commit 49ed60b

Browse files
authored
Fix protocol version checking (#2737)
1 parent f1aa582 commit 49ed60b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

redis/asyncio/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def __init__(
255255

256256
self.response_callbacks = CaseInsensitiveDict(self.__class__.RESPONSE_CALLBACKS)
257257

258-
if self.connection_pool.connection_kwargs.get("protocol") == "3":
258+
if self.connection_pool.connection_kwargs.get("protocol") in ["3", 3]:
259259
self.response_callbacks.update(self.__class__.RESP3_RESPONSE_CALLBACKS)
260260

261261
# If using a single connection client, we need to lock creation-of and use-of

redis/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ def __init__(
11091109

11101110
self.response_callbacks = CaseInsensitiveDict(self.__class__.RESPONSE_CALLBACKS)
11111111

1112-
if self.connection_pool.connection_kwargs.get("protocol") == "3":
1112+
if self.connection_pool.connection_kwargs.get("protocol") in ["3", 3]:
11131113
self.response_callbacks.update(self.__class__.RESP3_RESPONSE_CALLBACKS)
11141114

11151115
def __repr__(self):

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,4 +479,4 @@ def is_resp2_connection(r):
479479
protocol = r.connection_pool.connection_kwargs.get("protocol")
480480
elif isinstance(r, redis.RedisCluster):
481481
protocol = r.nodes_manager.connection_kwargs.get("protocol")
482-
return protocol == "2" or protocol is None
482+
return protocol in ["2", 2, None]

0 commit comments

Comments
 (0)