diff options
author | andy <andy@whiskeymedia.com> | 2012-08-14 09:50:01 -0700 |
---|---|---|
committer | andy <andy@whiskeymedia.com> | 2012-08-14 09:50:01 -0700 |
commit | ae6ceae93826d5359467b1f6b518f70e60985f5e (patch) | |
tree | ba1c577731b57459054257f915da59083f6b1b50 | |
parent | 331949d23333e12fa96abddc16c902f96ca5fe04 (diff) | |
download | redis-py-ae6ceae93826d5359467b1f6b518f70e60985f5e.tar.gz |
Raise an exception if there's any kind of error. Fix for #251.
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | redis/connection.py | 11 |
2 files changed, 9 insertions, 4 deletions
@@ -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 |