Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix getitem syntax for redis get when value is the empty string #679

Merged
merged 1 commit into from
Nov 26, 2015

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants