Skip to content

Commit

Permalink
Always return a set object from set-based commands. Thanks Adam Charn…
Browse files Browse the repository at this point in the history
…ock for the bug report.
  • Loading branch information
andymccurdy committed Apr 19, 2010
1 parent 80c248c commit 18f2a02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions redis/client.py
Expand Up @@ -212,7 +212,7 @@ class Redis(threading.local):
lambda r: r == 'OK'
),
string_keys_to_dict('SDIFF SINTER SMEMBERS SUNION',
lambda r: r and set(r) or r
lambda r: set(r)
),
string_keys_to_dict('ZRANGE ZRANGEBYSCORE ZREVRANGE', zset_score_pairs),
{
Expand Down Expand Up @@ -342,8 +342,9 @@ def _parse_response(self, command_name, catch_errors):
return [self._parse_response(command_name, catch_errors)
for i in range(length)]
else:
# for pipelines, we need to read everything, including response errors.
# otherwise we'd completely mess up the receive buffer
# for pipelines, we need to read everything,
# including response errors. otherwise we'd
# completely mess up the receive buffer
data = []
for i in range(length):
try:
Expand Down
2 changes: 2 additions & 0 deletions tests/server_commands.py
Expand Up @@ -460,6 +460,8 @@ def test_smembers(self):
self.client['a'] = 'a'
self.assertRaises(redis.ResponseError, self.client.smembers, 'a')
del self.client['a']
# set doesn't exist
self.assertEquals(self.client.smembers('a'), set())
# real logic
self.make_set('a', 'abc')
self.assertEquals(self.client.smembers('a'), set(['a', 'b', 'c']))
Expand Down

0 comments on commit 18f2a02

Please sign in to comment.