summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXabier Eizmendi <xeizmendi@gmail.com>2019-01-10 15:15:42 +0100
committerXabier Eizmendi <xeizmendi@gmail.com>2019-01-10 15:27:28 +0100
commite5d53dd7bffc7d0876efafc3445746e534b21855 (patch)
tree037da7412ec1a19b45b7146c85250377b088841a
parenta3cfded93afa2a65908f05ac251b18d77fa84dd2 (diff)
downloadredis-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-xredis/client.py2
-rw-r--r--tests/test_commands.py16
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'