summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy McCurdy <andy@andymccurdy.com>2011-06-10 10:56:48 +0200
committerAndy McCurdy <andy@andymccurdy.com>2011-06-10 10:56:48 +0200
commit97f0d20db8175990be67fc1ed86375079f92a2af (patch)
tree65e73932f1a25caa81e29a693272a33919cc4597
parent4103be272bd886498ec850ea7d5ce5c3b4979014 (diff)
downloadredis-py-97f0d20db8175990be67fc1ed86375079f92a2af.tar.gz
fix for PythonParser when reading empty strings
-rw-r--r--redis/connection.py2
-rw-r--r--tests/server_commands.py5
2 files changed, 6 insertions, 1 deletions
diff --git a/redis/connection.py b/redis/connection.py
index d005430..2b48e32 100644
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -57,7 +57,7 @@ class PythonParser(object):
length = int(response)
if length == -1:
return None
- response = length and self.read(length) or ''
+ response = self.read(length)
return response
# multi-bulk response
elif byte == '*':
diff --git a/tests/server_commands.py b/tests/server_commands.py
index 9d82eac..f3fd524 100644
--- a/tests/server_commands.py
+++ b/tests/server_commands.py
@@ -1009,6 +1009,11 @@ class ServerCommandsTestCase(unittest.TestCase):
self.assertEqual(self.client.hgetall('foo'), d)
self.assertRaises(redis.DataError, self.client.hmset, 'foo', {})
+ def test_hmset_empty_value(self):
+ d = {'a': '1', 'b': '2', 'c': ''}
+ self.assert_(self.client.hmset('foo', d))
+ self.assertEqual(self.client.hgetall('foo'), d)
+
def test_hmget(self):
d = {'a': 1, 'b': 2, 'c': 3}
self.assert_(self.client.hmset('foo', d))