summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redis/client.py5
-rw-r--r--tests/server_commands.py1
2 files changed, 4 insertions, 2 deletions
diff --git a/redis/client.py b/redis/client.py
index 9bf848c..f5a6283 100644
--- a/redis/client.py
+++ b/redis/client.py
@@ -500,10 +500,11 @@ class StrictRedis(object):
``start`` and ``end`` paramaters indicate which bytes to consider
"""
params = [key]
- if start and end:
+ if start is not None and end is not None:
params.append(start)
params.append(end)
- elif (start and not end) or (end and not start):
+ elif (start is not None and end is None) or \
+ (end is not None and start is None):
raise RedisError("Both start and end must be specified")
return self.execute_command('BITCOUNT', *params)
diff --git a/tests/server_commands.py b/tests/server_commands.py
index dcc7e2a..78f9bb8 100644
--- a/tests/server_commands.py
+++ b/tests/server_commands.py
@@ -251,6 +251,7 @@ class ServerCommandsTestCase(unittest.TestCase):
self.client.setbit('a', 25, True)
self.client.setbit('a', 33, True)
self.assertEquals(self.client.bitcount('a'), 5)
+ self.assertEquals(self.client.bitcount('a', 0, -1), 5)
self.assertEquals(self.client.bitcount('a', 2, 3), 2)
self.assertEquals(self.client.bitcount('a', 2, -1), 3)
self.assertEquals(self.client.bitcount('a', -2, -1), 2)