redis / redis-py

Redis Python client
MIT License
12.64k stars 2.52k forks source link

smembers() fails on inexistent key #53

Closed Suor closed 14 years ago

Suor commented 14 years ago

Redis server returns nil, then client tries to set() it and fails with "NoneType is not iterable". Should return empty set in this case or at least None. Same for sinter() if any one of keys doesn't exist.

sumeet commented 14 years ago

I can't repeat that behavior:

>>> r = redis.Redis()
>>> r.flushdb()
True
>>> r.smembers('badkey')
set()

Can you provide a failing test case?

Suor commented 14 years ago

Doing the same as you and getting TypeError. redis 1.2.6, python 2.6.2

I think it's redis version, check what your redis is returning in redis-cli. Mine returns (nil)

DeadWisdom commented 14 years ago

I am also getting this problem. It would be really good if somewhere in the documentation it was stated what version of the redis client the tests were run against.

andymccurdy commented 14 years ago

The Redis client mimics the version of the server. Meaning the 2.0.X client should work against a 2.0.X server.

I've added a check in cab0380 for None which should fix this bug. See if this fixes your problems. If so, I'll roll a new pypi version.

DeadWisdom commented 14 years ago

Awesome, and that is very good to know, but you document that nowhere, it should be among the first things you tell me in the README.md file.

Thanks!

andymccurdy commented 14 years ago

It is in the Readme file... just at the bottom under "Versioning Scheme". You're probably right that it should be at the top. I'll make that change now.

Can you confirm if the latest patch fixed your SMEMBERS issue?

DeadWisdom commented 14 years ago

Personally, this problem went away when I got the correct server version.

Well that's what you get for me not reading fully. Ahem. Sorry about that.

andymccurdy commented 14 years ago

Ok, well closing for now. If anyone on an older server version does have issues, please re-open!