Le Mon, 03 Dec 2012 14:29:35 -0800, Larry Hastings <larry@hastings.org> a écrit :
/*[clinic] dbm.open -> mapping basename=dbmopen
const char *filename; The filename to open.
So how does it handle the fact that filename can either be a unicode string or a fsencoding-encoded bytestring? And how does it do the right encoding/decoding dance, possibly platform-specific?
static char *_keywords[] = {"filename", "flags", "mode", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|si", _keywords, &filename, &flags, &mode)) return NULL;
I see, it doesn't :-)
But the biggest unresolved question... is this all actually a terrible idea?
I like the idea, but it needs more polishing. I don't think the various "duck types" accepted by Python can be expressed fully in plain C types (e.g. you must distinguish between taking all kinds of numbers or only an __index__-providing number). Regards Antoine.