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

gets: Return (None, None) when key does not exist #87

Merged
merged 2 commits into from Apr 26, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion _pylibmcmodule.c
Expand Up @@ -518,7 +518,7 @@ static PyObject *PylibMC_Client_gets(PylibMC_Client *self, PyObject *arg) {
ret = NULL;
PyErr_SetString(PyExc_RuntimeError, "fetch not done");
}
} else if (rc == MEMCACHED_END) {
} else if (rc == MEMCACHED_END || rc == MEMCACHED_NOTFOUND) {
/* Key not found => (None, None) */
ret = Py_BuildValue("(OO)", Py_None, Py_None);
} else {
Expand Down
6 changes: 6 additions & 0 deletions tests/doctests.txt
Expand Up @@ -261,3 +261,9 @@ Test server/client max length
Traceback (most recent call last):
...
ValueError: key too long, max is 250

Gets should return (None, None) for non-existing keys
>>> c = make_test_client(_pylibmc.client, binary=True)
>>> c.set_behaviors({'cas': True})
>>> c.gets('non_existing_key')
(None, None)