[Python-checkins] python/dist/src/Modules readline.c,2.59,2.60
Michael Hudson
mwh@python.net
Fri, 31 Jan 2003 12:53:22 +0000
Guido van Rossum <guido@python.org> writes:
>> METH_NOARGS functions are still called with two arguments, one NULL,
>> so put that back into the function definitions (I didn't know this
>> until recently).
>
> Hm, isn't this a bug???
What, that most METH_NOARGS functions are defined
mod_foo(PyObject* self)
or that the call in ceval.c:3211 is
x = (*meth)(self, NULL);
? Tim said in a comment on patch #660559:
Note that a METH_NOARGS function is still called, at the C
level, with two arguments. The second argument is always
NULL, and sooner or later some platform C is going to blow
up when that's passed to a function declared to take only
one argument ("the usual" cast to PyCFunction shuts up the
compile-time warnings).
It's not your job to fix that everywhere, but new uses of
METH_NOARGS shouldn't add to this problem. Declaring a
second PyObject * argument with a name like "unused"
or "dummy" would be fine.
As I was mucking about with readline.c anyway, I thought I'd put in
the unused argument and take out the casts.
Cheers,
M.
--
There's a difference between random people with stripy jumpers,
and a respected scientist with a reputation.
-- Steve Kitson, ucam.chat