PyArg_ParseTupleAndKeywords and optional unicode arguments

Roger Upole rupole at
Mon Dec 1 10:22:52 CET 2003

I'm having a problem with an extension module using
PyArg_ParseTupleAndKeywords with 2.3.2.
Distilled down:

PyObject *wtf(PyObject *self, PyObject *args, PyObject *kwargs)
 WCHAR *dummy1=NULL;
 WCHAR *dummy2=NULL;
 WCHAR *dummy3=NULL;
 static char *dummyelements[]={"dummy1","dummy2","dummy3",0};
 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|uuu:wtf", dummyelements,
&dummy1, &dummy2, &dummy3))
  return NULL;
 return Py_None;

>>> wtf(dummy1=u'xxxxxx',dummy3=u'dummy3')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: wtf() argument 2 impossible<bad format char>
[17300 refs]

Anybody seen this before, or is this a known problem, or am I just missing
something obvious ?
Any help greatly appreciated.

More information about the Python-list mailing list