diff options
author | Xabier Eizmendi <xeizmendi@gmail.com> | 2019-01-10 15:15:42 +0100 |
---|---|---|
committer | Xabier Eizmendi <xeizmendi@gmail.com> | 2019-01-10 15:27:28 +0100 |
commit | e5d53dd7bffc7d0876efafc3445746e534b21855 (patch) | |
tree | 037da7412ec1a19b45b7146c85250377b088841a | |
parent | a3cfded93afa2a65908f05ac251b18d77fa84dd2 (diff) | |
download | redis-py-e5d53dd7bffc7d0876efafc3445746e534b21855.tar.gz |
Fix #1116 - trimmed stream causes exception on xreadgroup with id 0
messages
Signed-off-by: Xabier Eizmendi <xeizmendi@gmail.com>
-rwxr-xr-x | redis/client.py | 2 | ||||
-rw-r--r-- | tests/test_commands.py | 16 |
2 files changed, 18 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py index 2645e83..154ddc1 100755 --- a/redis/client.py +++ b/redis/client.py @@ -191,6 +191,8 @@ def parse_sentinel_get_master(response): def pairs_to_dict(response, decode_keys=False): "Create a dict given a list of key/value pairs" + if response is None: + return {} if decode_keys: # the iter form is faster, but I don't know how to make that work # with a nativestr() map diff --git a/tests/test_commands.py b/tests/test_commands.py index 566437d..73a0052 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -2205,6 +2205,22 @@ class TestRedisCommands(object): # xread starting after the last message returns an empty message list assert r.xreadgroup(group, consumer, streams={stream: '>'}) == expected + r.xgroup_destroy(stream, group) + r.xgroup_create(stream, group, '0') + # delete all the messages in the stream + expected = [ + [ + stream.encode(), + [ + (m1, {}), + (m2, {}), + ] + ] + ] + r.xreadgroup(group, consumer, streams={stream: '>'}) + r.xtrim(stream, 0) + assert r.xreadgroup(group, consumer, streams={stream: '0'}) == expected + @skip_if_server_version_lt('5.0.0') def test_xrevrange(self, r): stream = 'stream' |