summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandy <andy@whiskeymedia.com>2012-08-14 09:50:01 -0700
committerandy <andy@whiskeymedia.com>2012-08-14 09:50:01 -0700
commitae6ceae93826d5359467b1f6b518f70e60985f5e (patch)
treeba1c577731b57459054257f915da59083f6b1b50
parent331949d23333e12fa96abddc16c902f96ca5fe04 (diff)
downloadredis-py-ae6ceae93826d5359467b1f6b518f70e60985f5e.tar.gz
Raise an exception if there's any kind of error. Fix for #251.
-rw-r--r--CHANGES2
-rw-r--r--redis/connection.py11
2 files changed, 9 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 5226b3c..28c2248 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
* 2.6.1 (in development)
* Python 3.x support! Big thanks to Alex Grönholm.
+ * Fixed a bug in the PythonParser's read_response that could hide an error
+ from the client (#251).
* 2.6.0
* Changed (p)subscribe and (p)unsubscribe to no longer return messages
indicating the channel was subscribed/unsubscribed to. These messages
diff --git a/redis/connection.py b/redis/connection.py
index a6a8caf..5a2d8df 100644
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -96,13 +96,16 @@ class PythonParser(object):
# server returned an error
if byte == '-':
- if nativestr(response).startswith('ERR '):
- response = response[4:]
- return ResponseError(response)
if nativestr(response).startswith('LOADING '):
- # If we're loading the dataset into memory, kill the socket
+ # if we're loading the dataset into memory, kill the socket
# so we re-initialize (and re-SELECT) next time.
raise ConnectionError("Redis is loading data into memory")
+ # if the error starts with ERR, trim that off
+ if nativestr(response).startswith('ERR '):
+ response = response[4:]
+ # *return*, not raise the exception class. if it is meant to be
+ # raised, it will be at a higher level.
+ return ResponseError(response)
# single value
elif byte == '+':
pass