[Python-Dev] int/long FutureWarning (original) (raw)

Martin v. L�wis martin@v.loewis.de
30 Nov 2002 01:26:57 +0100


Jack Jansen <Jack.Jansen@oratrix.com> writes:

How about taking a completely different angle on this matter, and looking at PyArgParse itself? If we can keep PyArgParse 100% backward compatible (which would mean that its "i" format would take any IntObject or LongObject between -1e31 and 1e32-1) and introduce a new (preferred) way to parse arguments that not only does the right thing by being expressive enough to make a difference between "currency integers" and "bitmap integers", but also cleans up the incredible amount of cruft that PyArgParse has accumulated over the years?

I had a similar idea, so I'd encourage you to spell out your proposal in more detail, or even in an implementation.

My idea was to provide a ParseTuple wrapper, which would be like

int PyArg_ParseTupleLenient(PyObject *args, char *format, ...) { char format1[200]; int retval; va_list va;

    for(int i = 0; format[i]; i++)
      format1[i] = lenient_format(format[i]);

va_start(va, format);
retval = PyArg_VaParse(args, format1, va);
va_end(va);
return retval;

}

This would replace the "i" format with a "k" format, and perhaps make other changes to the format.

Those of you needing to support older Python releases could

#define PyArg_ParseTupleLenient PyArg_ParseTuple

in your distribution, or provide other appropriate wrappers.

Regards, Martin