From f88c8c3afec7c205caf34cb8028b5f9d7799c35a Mon Sep 17 00:00:00 2001 From: lericson Date: Mon, 10 May 2010 12:42:46 +0200 Subject: [PATCH] Stop accepting time argument for delete. Fixes #1 --- _pylibmcmodule.c | 12 +++++------- tests.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/_pylibmcmodule.c b/_pylibmcmodule.c index f8218f0..c81af2d 100644 --- a/_pylibmcmodule.c +++ b/_pylibmcmodule.c @@ -520,15 +520,13 @@ static PyObject *PylibMC_Client_delete(PylibMC_Client *self, PyObject *args) { PyObject *retval; char *key; Py_ssize_t key_sz; - unsigned int time; memcached_return rc; retval = NULL; - time = 0; - if (PyArg_ParseTuple(args, "s#|I", &key, &key_sz, &time) + if (PyArg_ParseTuple(args, "s#:delete", &key, &key_sz) && _PylibMC_CheckKeyStringAndSize(key, key_sz)) { Py_BEGIN_ALLOW_THREADS; - rc = memcached_delete(self->mc, key, key_sz, time); + rc = memcached_delete(self->mc, key, key_sz, 0); Py_END_ALLOW_THREADS; switch (rc) { case MEMCACHED_SUCCESS: @@ -893,10 +891,10 @@ static PyObject *PylibMC_Client_delete_multi(PylibMC_Client *self, PyObject *call_args; PyObject *retval; - static char *kws[] = { "keys", "time", "key_prefix", NULL }; + static char *kws[] = { "keys", "key_prefix", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O!S", kws, - &keys, &PyInt_Type, &time, &prefix)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|S:delete_multi", kws, + &keys, &prefix)) return NULL; /** diff --git a/tests.py b/tests.py index 4846d9a..9d13cb7 100644 --- a/tests.py +++ b/tests.py @@ -80,6 +80,17 @@ True >>> c.get("hi") >>> +See issue #1 ``http://github.com/lericson/pylibmc/issues/#issue/1`` -- delete +should not accept a time argument. +>>> c.delete("foo", 123) +Traceback (most recent call last): + ... +TypeError: delete() takes exactly 1 argument (2 given) +>>> c.delete_multi(["foo"], time=123) +Traceback (most recent call last): + ... +TypeError: 'time' is an invalid keyword argument for this function + Now for keys with funny types. >>> c.set(1, "hi") Traceback (most recent call last):