Python 2.4 compile failure (Re: [PATCH 24/28] introduce gdb_pymodule_addobject)

Ulrich Weigand
2013-06-03T12:50:06Z

Tom Tromey wrote:

> +int
> +gdb_pymodule_addobject (PyObject *module, const char *name, PyObject *object)
> +{
> + int result;
> +
> + Py_INCREF (object);
> + result = PyModule_AddObject (module, name, object);
> + if (result < 0)
> + Py_DECREF (object);
> + return result;
> +}

This causes compile failures on one of our build servers which is
still using RHEL5 (which has Python 2.4 installed by default):

/home/kwerner/dailybuild/spu-tc-2013-06-02/gdb-head/src/gdb/python/py-utils.c: In function 'gdb_pymodule_addobject':
/home/kwerner/dailybuild/spu-tc-2013-06-02/gdb-head/src/gdb/python/py-utils.c:439: warning: passing argument 2 of 'PyModule_AddObject' discards qualifiers from pointer target type

The problem seems to be that in Python 2.4, gdb_pymodule_addobject takes
a "char *" instead of a "const char *":

/usr/include/python2.4/modsupport.h:PyAPI_FUNC(int) PyModule_AddObject(PyObject *, char *, PyObject *);

Now I guess 2.4 is quite old, but it is still supported according to
GDB documentation (and there are some special cases in the sources) ...

Should this be fixed?

Bye,
Ulrich

--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com