[Python-Dev] Use of PyArg_NoArgs()
Guido van Rossum
guido@python.org
Mon, 25 Mar 2002 18:00:12 -0500
> Guido van Rossum wrote:
> >
> > > Python/sysmodule.c: {"exit", METH_OLDARGS,
> >
> > This one *appears* tricky. But in fact, changing it to METH_VARARGS
> > should work just as well (I think).
[Neal]
> The only problem I ran into just using METH_VARARGS is that
> the parameter is always printed.
Oops. That's wrong.
> So I used PyArg_ParseTuple()
> and passed that object to PyErr_SetObject(PyExc_SystemExit, exit_code).
> This works as before wrt printing. However, you can no longer
> pass an arbitrary number of parameters, either 0 or 1. Is this ok?
It's documented as having one optional arg. It might break code if we
disallow multiple args, but I don't think I care. So, yes, OK.
> > > On a related note, PyArg_GetInt() macro is used exactly one time--
> > > in socketmodule.c There seem to be many more places where this
> > > could be used. Should I use or remove the macro? Or doc
> > > that it should not be used?
> >
> > It's deprecated, just as PyArg_NoArgs(). Now's a good time to get rid
> > of the last usage instance.
>
> Both PyArg_GetInt() & PyArg_NoArgs() both have comments above them
> stating they should not be used. There are no more occurances
> of PyArg_GetInt(). I'm working on reducing METH_OLDARGS, down to 214.
>
> If you want I can remove them from Include/Python.h when done.
Has the api documentation documented them as obsolete? If so, or if
they were undocumented, yes, please remove them. If not, I'd see if
there's a way to turn these into warnings for one release.
> If so, should I write up anything in NEWS?
Yes, I think so. It's always good to announce explicitly when
a previously deprecated item actually gets deleted, no matter how
small.
--Guido van Rossum (home page: http://www.python.org/~guido/)