[Python-Dev] Use of PyArg_NoArgs()

Neal Norwitz neal@metaslash.com
Mon, 25 Mar 2002 15:39:43 -0500


"Martin v. Loewis" wrote:
> 
> Neal Norwitz <neal@metaslash.com> writes:
> 
> > Should the use of PyArg_NoArgs() be deprecated?
> >
> > There are many uses (53) throughout Modules/*.c.  It seems that this
> > check is not useful anymore if the MethodDef is set to METH_NOARGS.
> > Is this correct?  If so, I can make a patch.
> 
> I would prefer if you could simultaneously remove occurences of
> METH_OLDARGS (introducing METH_O where possible), so that modules get
> cleaned-up entirely, rather than just replacing the easy parts :-)

Ok, I guess I can go a little further... :-)

There are about 238 uses of METH_OLDARGS, all but 2 are in Modules/.
I don't know how to fix the other 2:

Objects/fileobject.c:   {"readinto", METH_OLDARGS, 
Python/sysmodule.c:     {"exit",     METH_OLDARGS, 

But I will take a look at the other Modules.

> The reason why such changes haven't been applied to all modules is
> that some of the modules are old in themselves, and I would have no
> way to verify that the module is working properly after the changes.

Yes, this could be a problem, but it is very early on in 2.3.  
But if the modules aren't used at all, no one will notice. :-)

I will start by checking in all the more current modules:  
	_curses_panel, _localemodule, bsddbmodule, md5module, 
	pwdmodule, readline, signalmodule, threadmodule

Other modules which I've fixed, but can't test:  
	clmodule, flmodule, fmmodule, glmodule, nismodule

nis should be testable by someone.

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?

Neal