summaryrefslogtreecommitdiff
path: root/redis
diff options
context:
space:
mode:
Diffstat (limited to 'redis')
-rw-r--r--redis/__init__.py15
-rw-r--r--redis/client.py13
-rw-r--r--redis/exceptions.py2
3 files changed, 23 insertions, 7 deletions
diff --git a/redis/__init__.py b/redis/__init__.py
index 894f8e1..499f658 100644
--- a/redis/__init__.py
+++ b/redis/__init__.py
@@ -1,12 +1,19 @@
# legacy imports
from redis.client import Redis, ConnectionPool
-from redis.exceptions import RedisError, ConnectionError, AuthenticationError
-from redis.exceptions import ResponseError, InvalidResponse, InvalidData
+from redis.exceptions import (
+ AuthenticationError,
+ ConnectionError,
+ DataError,
+ InvalidResponse,
+ RedisError,
+ ResponseError,
+ )
+
__version__ = '2.2.3'
__all__ = [
'Redis', 'ConnectionPool',
- 'RedisError', 'ConnectionError', 'ResponseError', 'AuthenticationError'
- 'InvalidResponse', 'InvalidData',
+ 'RedisError', 'ConnectionError', 'ResponseError', 'AuthenticationError',
+ 'InvalidResponse', 'DataError',
]
diff --git a/redis/client.py b/redis/client.py
index 2c7e404..8e85a90 100644
--- a/redis/client.py
+++ b/redis/client.py
@@ -4,8 +4,15 @@ import time
import warnings
from itertools import chain, imap, islice, izip
from redis.connection import ConnectionPool, Connection
-from redis.exceptions import ConnectionError, ResponseError, WatchError
-from redis.exceptions import RedisError, AuthenticationError
+from redis.exceptions import (
+ AuthenticationError,
+ ConnectionError,
+ DataError,
+ RedisError,
+ ResponseError,
+ WatchError,
+)
+
def list_or_args(command, keys, args):
# returns a single list combining keys and args
@@ -1145,6 +1152,8 @@ class Redis(threading.local):
in the hash ``name``
"""
items = []
+ if len(mapping) == 0:
+ raise DataError
for pair in mapping.iteritems():
items.extend(pair)
return self.execute_command('HMSET', name, *items)
diff --git a/redis/exceptions.py b/redis/exceptions.py
index b3257ac..193016e 100644
--- a/redis/exceptions.py
+++ b/redis/exceptions.py
@@ -15,7 +15,7 @@ class ResponseError(RedisError):
class InvalidResponse(RedisError):
pass
-class InvalidData(RedisError):
+class DataError(RedisError):
pass
class WatchError(RedisError):