summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarpentier Pierre-Francois <carpentier.pf@gmail.com>2013-05-15 17:03:23 -0300
committerCarpentier Pierre-Francois <carpentier.pf@gmail.com>2013-05-15 17:03:23 -0300
commit9e0ca54f3f147f5271fa7a1f0159c256bd5b1b84 (patch)
treeaa1a18e1d5137a8c2052a46404f5fde0975bd0da
parentb5214ab814b6c35aa8f880ef61c0719b851e60e0 (diff)
downloadredis-py-9e0ca54f3f147f5271fa7a1f0159c256bd5b1b84.tar.gz
error in the __call__ method of class Script
If "client" is a pipeline, and this pipeline is empty, python converts "client" to False when casting in bool because Class BasePipeline has a method __len__. "client" is reset to self.registered_client, and the script is not executed in the pipeline as it should. The correct test is to check if "client" equals None. see http://stackoverflow.com/questions/100732/why-is-if-not-someobj-better-than-if-someobj-none-in-python for bool conversion (first answer).
-rw-r--r--redis/client.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/redis/client.py b/redis/client.py
index 033fd3d..1abe37a 100644
--- a/redis/client.py
+++ b/redis/client.py
@@ -1969,7 +1969,8 @@ class Script(object):
def __call__(self, keys=[], args=[], client=None):
"Execute the script, passing any required ``args``"
- client = client or self.registered_client
+ if client == None:
+ client = self.registered_client
args = tuple(keys) + tuple(args)
# make sure the Redis server knows about the script
if isinstance(client, BasePipeline):