You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: Calling slowlog_get() on a redis.Redis client instance with decode_responses=True raises a TypeError:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 1192, in slowlog_get
return self.execute_command(*args)
File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 839, in execute_command
return self.parse_response(conn, command_name, **options)
File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 859, in parse_response
return self.response_callbacks[command_name](response, **options)
File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 397, in parse_slowlog_get
} for item in response]
File "/Users/.../lib/python3.7/site-packages/redis/client.py", line 397, in <listcomp>
} for item in response]
TypeError: sequence item 0: expected a bytes-like object, str found
The command executes just fine when decode_responses=False (default).
Of course, this no longer handles the default case (decode_responses=False).
There are various ways to address this issue, including:
Somehow pass the value of decode_responses and substitute b' ' by ' ' where appropriate (is this relevant in other places, too?)
Determine type of list members (bytes vs. str) and use appropriate whitespace type
Optimistically keep the current implementation, but wrap it in a try-except block and retry with alternative implementation on exception
I am leaning towards option 1 and would be willing to create a PR, if it helps. Since I'm a noob here, it would help if you could point me to a similar issue for guidance. Thanks!
The text was updated successfully, but these errors were encountered:
Version: redis-py 3.3.11 and AWS ElastiCache Redis 5.0.5 (Cluster mode off, 1 shard, 2 nodes)
Platform: Python 3.7.5 on macOS Catalina 10.15.1
Description: Calling slowlog_get() on a redis.Redis client instance with decode_responses=True raises a TypeError:
The command executes just fine when decode_responses=False (default).
As a preliminary work-around, I replaced the type of whitespace used on line 396 in parse_slowlog_get() of client.py (bytes -> str):
'command': ' '.join(item[3])
(removeb
)Of course, this no longer handles the default case (decode_responses=False).
There are various ways to address this issue, including:
I am leaning towards option 1 and would be willing to create a PR, if it helps. Since I'm a noob here, it would help if you could point me to a similar issue for guidance. Thanks!
The text was updated successfully, but these errors were encountered: