[Python-Dev] Remove METH_OLDARGS?

Neal Norwitz nnorwitz at gmail.com
Mon May 29 06:37:34 CEST 2006


On 5/28/06, Georg Brandl <g.brandl at gmx.net> wrote:
> Neal Norwitz wrote:
> > On 5/28/06, Georg Brandl <g.brandl at gmx.net> wrote:
> >> In the process of reviewing and possibly extending getargs.c, I stumbled
> >> over the "compatibility" flag supposedly used for METH_OLDARGS functions.
> >> No code in the core uses this calling convention any more, and it has been
> >> deprecated for quite a long time (since 2.2), so would it be appropriate to end
> >> support for it in 2.5?
> >
> > There's still a ton used under Modules.  Also, if no flag is
> > specified, it will default to 0 (ie, METH_OLDARGS).  I wonder how many
> > third party modules use METH_OLDARGS directly or more likely
> > indirectly.
>
> These modules can be converted.

We can convert the one's in Python, but not the third party ones.
It's also very difficult to search for something that's not there.
You need to review every PyMethodDef entry to verify it has a METH_*
flag.  These implicit METH_OLDARGS may well exist in Python,
especially given who did the patch to add them in the first place. :-)

    http://mail.python.org/pipermail/python-dev/2002-March/022009.html
    http://mail.python.org/pipermail/patches/2002-July/009023.html

> > I would like to get rid of the flag, but I'm not sure we can do it
> > safely until 3.0.
>
> It has been deprecated since 2.2, so it'd be no surprise if it went away.

There's a difference between "it'd be no surprise" and "it should be
no surpise".  While I agree in theory they are the same, in practice,
they are not.  That's the difference between theory and practice. :-)

> Also, it would be easy to detect METH_OLDARGS in PyCFunction_New and raise
> an appropriate exception.

I agree with Martin this should raise a deprecation warning in 2.5.

n


More information about the Python-Dev mailing list