summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo <tunedconsulting@gmail.com>2017-07-19 16:18:33 +0100
committerGitHub <noreply@github.com>2017-07-19 16:18:33 +0100
commit1239206848760e5c2301fe835775012828cb934f (patch)
tree82e66e067228b6e469fe53d1655a4627366790e8
parentd6c300b39ab4c81cd97b81fcd8d25a9cde9476e7 (diff)
downloadredis-py-1239206848760e5c2301fe835775012828cb934f.tar.gz
Improve if statement throwing KeyError
At line 210, if WITHSCORES is not specified within `execute_command()`, this line used to throw a `KeyError` because the relative key in `options` is not present. Solution: this PR add a check on the key 'withscores' before the key is accessed.
-rwxr-xr-xredis/client.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/redis/client.py b/redis/client.py
index 98764ca..4ecfb57 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -207,7 +207,7 @@ def zset_score_pairs(response, **options):
If ``withscores`` is specified in the options, return the response as
a list of (value, score) pairs
"""
- if not response or not options['withscores']:
+ if not response or 'withscores' not in options.keys() or options['withscores'] is None:
return response
score_cast_func = options.get('score_cast_func', float)
it = iter(response)