[Python-Dev] Baffled by PyArg_ParseTupleAndKeywords modification

"Martin v. Löwis" martin at v.loewis.de
Fri Feb 10 20:33:42 CET 2006

Tim Peters wrote:
>>Sigh.  I don't see any way to avoid a warning in Jack's case.
> Martin's turn ;-)

I see two options:

1. Revert the change for the const char** keywords argument (but
   leave the change for everything else). C++ users should only
   see a problem if they have a const char* variable, not if
   they use literals (Jeremy's compiler's warning is insensate)

   For keyword arguments, people typically don't have char*
   variables; instead, they have an array of string literals.

2. Only add the const in C++:

#ifdef __cplusplus
#define Py_cxxconst const
#define Py_cxxconst

   PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
       const char *, Py_cxxconst char *Py_cxxconst*, ...);

   This might look like it could break C/C++ interoperability on
   platforms that take an inventive interpretation of standard
   (e.g. if they would mangle even C symbols). However, I believe
   it won't make things worse: The C++ standard doesn't guarantee
   interoperability of C and C++ implementations at all, and the
   platforms I'm aware of support the above construct (since
   PA_PTAK is extern "C").


More information about the Python-Dev mailing list