diff options
-rwxr-xr-x | redis/client.py | 2 | ||||
-rw-r--r-- | tests/test_commands.py | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/redis/client.py b/redis/client.py index c40662f..e426abe 100755 --- a/redis/client.py +++ b/redis/client.py @@ -885,7 +885,7 @@ class StrictRedis(object): doesn't exist. """ value = self.get(name) - if value: + if value is not None: return value raise KeyError(name) diff --git a/tests/test_commands.py b/tests/test_commands.py index 45206b2..7293810 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -341,6 +341,10 @@ class TestRedisCommands(object): with pytest.raises(KeyError): r['a'] + def test_getitem_does_not_raise_keyerror_for_empty_string(self, r): + r['a'] = b("") + assert r['a'] == b("") + def test_get_set_bit(self, r): # no value assert not r.getbit('a', 5) |