summaryrefslogtreecommitdiff
path: root/redis/client.py
diff options
context:
space:
mode:
authorChayim <chayim@users.noreply.github.com>2021-11-25 14:18:33 +0200
committerGitHub <noreply@github.com>2021-11-25 14:18:33 +0200
commitd7b56103ed4d0ba9c05c74ca5580c72fcb70c09c (patch)
tree943b5df36eea7d2e37d50be626158461ecf41485 /redis/client.py
parent8991370332e818cf9886cec6adc1858189b04bd6 (diff)
downloadredis-py-d7b56103ed4d0ba9c05c74ca5580c72fcb70c09c.tar.gz
Adding support for non-decodable commands (#1731)
Diffstat (limited to 'redis/client.py')
-rwxr-xr-xredis/client.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/redis/client.py b/redis/client.py
index 143ed88..30a5c3c 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -27,6 +27,9 @@ from redis.utils import safe_str, str_if_bytes
SYM_EMPTY = b''
EMPTY_RESPONSE = 'EMPTY_RESPONSE'
+# some responses (ie. dump) are binary, and just meant to never be decoded
+NEVER_DECODE = 'NEVER_DECODE'
+
def timestamp_to_datetime(response):
"Converts a unix timestamp to a Python datetime object"
@@ -1106,7 +1109,10 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands, object):
def parse_response(self, connection, command_name, **options):
"Parses a response from the Redis server"
try:
- response = connection.read_response()
+ if NEVER_DECODE in options:
+ response = connection.read_response(disable_decoding=True)
+ else:
+ response = connection.read_response()
except ResponseError:
if EMPTY_RESPONSE in options:
return options[EMPTY_RESPONSE]