Re: [Python-Dev] [Python-3000] How to specify keyword-only arguments from C?
On Thu, Jun 5, 2008 at 11:18 PM, Alexandre Vassalotti
On Thu, Jun 5, 2008 at 10:14 PM, Mark Hammond
wrote: Set an error if the 'arg' tuple doesn't have a length of zero?
Oh, that isn't a bad idea at all. I will try this. Thanks!
Worked flawlessly! Just for the archives, here's how it looks like: static int Unpickler_init(UnpicklerObject *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"file", "encoding", "errors", 0}; PyObject *file; char *encoding = NULL; char *errors = NULL; if (Py_SIZE(args) != 1) { PyErr_Format(PyExc_TypeError, "%s takes exactly one 1 positional argument (%zd given)", Py_TYPE(self)->tp_name, Py_SIZE(args)); return -1; } if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|ss:Unpickler", kwlist, &file, &encoding, &errors)) return -1; ... Thank you, Mark, for the tip! -- Alexandre
participants (1)
-
Alexandre Vassalotti