[Python-Dev] Baffled by PyArg_ParseTupleAndKeywords modification (original) (raw)

Guido van Rossum guido at python.org
Fri Feb 10 16:39:53 CET 2006


OMG. Are we now adding 'const' modifiers to random places? I thought "const propagation hell" was a place we were happily avoiding by not falling for that meme. What changed?

--Guido

On 2/10/06, Jack Jansen <Jack.Jansen at cwi.nl> wrote:

I keep running into problems with the "const" modifications to PyArgParseTupleAndKeywords() (rev. 41638 by Jeremy).

I have lots of code of the form char *kw[] = {"itself", 0}; if (PyArgParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObjConvert, &itself)) ... which now no longer compiles, neither with C nor with C++ (gcc4, both MacOSX and Linux). Changing the kw declaration to "const char *kw[]" makes it compile again. I don't understand why it doesn't compile: even though the PyArgParseTupleAndKeywords signature promises that it won't change the "kw" argument I see no reason why I shouldn't be able to pass a non-const argument. And to make matters worse adding the "const" of course makes the code non-portable to previous versions of Python (where the C compiler rightly complains that I'm passing a const object through a non-const parameter). Can anyone enlighten me? -- Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list