Skip to content

Conversation

@candeira
Copy link
Contributor

When using __getitem__ syntax to retrieve an empty string, an exception is produced, just as if the key were unset:

>>> r = Redis(**connection_data) >>> print(r.get('bah')) None >>>r['bah'] KeyError: 'bah' >>> r['bah'] = "" >>> r.get('bah') b'' >>> r['bah'] KeyError: 'bah' 

The behaviour should be the same as for any other set value, and the exception only produced for unset keys:

>>> r['bah'] = "" >>> r.get('bah') b'' >>> r['bah'] b'' 

This patch provides a test and a fix.

@andymccurdy
Copy link
Contributor

Thanks!

andymccurdy added a commit that referenced this pull request Nov 26, 2015
fix getitem syntax for redis get when value is the empty string
@andymccurdy andymccurdy merged commit 16c8af4 into redis:master Nov 26, 2015
@candeira candeira deleted the fix-getitem branch November 26, 2015 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants