Add const to several API functions that take char *.

In C++, it's an error to pass a string literal to a char* function
without a const_cast().  Rather than require every C++ extension
module to put a cast around string literals, fix the API to state the
const-ness.

I focused on parts of the API where people usually pass literals:
PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type
slots, etc.  Predictably, there were a large set of functions that
needed to be fixed as a result of these changes.  The most pervasive
change was to make the keyword args list passed to
PyArg_ParseTupleAndKewords() to be a const char *kwlist[].

One cast was required as a result of the changes:  A type object
mallocs the memory for its tp_doc slot and later frees it.
PyTypeObject says that tp_doc is const char *; but if the type was
created by type_new(), we know it is safe to cast to char *.
diff --git a/Include/cStringIO.h b/Include/cStringIO.h
index 66e1edb..290a103 100644
--- a/Include/cStringIO.h
+++ b/Include/cStringIO.h
@@ -38,7 +38,7 @@
   int(*creadline)(PyObject *, char **);
 
   /* Write a string to an output object*/
-  int(*cwrite)(PyObject *, char *, int);
+  int(*cwrite)(PyObject *, const char *, int);
 
   /* Get the output object as a Python string (returns new reference). */
   PyObject *(*cgetvalue)(PyObject *);
diff --git a/Include/ceval.h b/Include/ceval.h
index 9481506..6db0818 100644
--- a/Include/ceval.h
+++ b/Include/ceval.h
@@ -18,9 +18,11 @@
 #define PyEval_CallObject(func,arg) \
         PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
 
-PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj, char *format, ...);
+PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj,
+                                           const char *format, ...);
 PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
-                                        char *methodname, char *format, ...);
+                                         const char *methodname,
+                                         const char *format, ...);
 
 PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
 PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
@@ -60,8 +62,8 @@
 #  define _Py_MakeRecCheck(x)  (++(x) > _Py_CheckRecursionLimit)
 #endif
 
-PyAPI_FUNC(char *) PyEval_GetFuncName(PyObject *);
-PyAPI_FUNC(char *) PyEval_GetFuncDesc(PyObject *);
+PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
+PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
 
 PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);
 PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);
diff --git a/Include/import.h b/Include/import.h
index 572cb8a..45cc6c9 100644
--- a/Include/import.h
+++ b/Include/import.h
@@ -12,8 +12,8 @@
 PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
 	char *name, PyObject *co, char *pathname);
 PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
-PyAPI_FUNC(PyObject *) PyImport_AddModule(char *name);
-PyAPI_FUNC(PyObject *) PyImport_ImportModule(char *name);
+PyAPI_FUNC(PyObject *) PyImport_AddModule(const char *name);
+PyAPI_FUNC(PyObject *) PyImport_ImportModule(const char *name);
 PyAPI_FUNC(PyObject *) PyImport_ImportModuleEx(
 	char *name, PyObject *globals, PyObject *locals, PyObject *fromlist);
 PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
diff --git a/Include/methodobject.h b/Include/methodobject.h
index 9736dc3..c887d94 100644
--- a/Include/methodobject.h
+++ b/Include/methodobject.h
@@ -35,15 +35,15 @@
 PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
 
 struct PyMethodDef {
-    char	*ml_name;	/* The name of the built-in function/method */
+    const char	*ml_name;	/* The name of the built-in function/method */
     PyCFunction  ml_meth;	/* The C function that implements it */
     int		 ml_flags;	/* Combination of METH_xxx flags, which mostly
 				   describe the args expected by the C func */
-    char	*ml_doc;	/* The __doc__ attribute, or NULL */
+    const char	*ml_doc;	/* The __doc__ attribute, or NULL */
 };
 typedef struct PyMethodDef PyMethodDef;
 
-PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, char *);
+PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, const char *);
 
 #define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
 PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *, 
@@ -76,7 +76,7 @@
 } PyMethodChain;
 
 PyAPI_FUNC(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *,
-                                                  char *);
+                                            const char *);
 
 typedef struct {
     PyObject_HEAD
diff --git a/Include/modsupport.h b/Include/modsupport.h
index bc30c3f..7851683 100644
--- a/Include/modsupport.h
+++ b/Include/modsupport.h
@@ -9,22 +9,22 @@
 
 #include <stdarg.h>
 
-PyAPI_FUNC(int) PyArg_Parse(PyObject *, char *, ...);
-PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, char *, ...);
+PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
+PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
 PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
-                                                  char *, char **, ...);
-PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, char *, int, int, ...);
-PyAPI_FUNC(PyObject *) Py_BuildValue(char *, ...);
-PyAPI_FUNC(int) _PyArg_NoKeywords(char *funcname, PyObject *kw);
+                                                  const char *, const char **, ...);
+PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, int, int, ...);
+PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
+PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw);
 
-PyAPI_FUNC(int) PyArg_VaParse(PyObject *, char *, va_list);
+PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
 PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
-                                                  char *, char **, va_list);
-PyAPI_FUNC(PyObject *) Py_VaBuildValue(char *, va_list);
+                                                  const char *, const char **, va_list);
+PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
 
-PyAPI_FUNC(int) PyModule_AddObject(PyObject *, char *, PyObject *);
-PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, char *, long);
-PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, char *, char *);
+PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *);
+PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
+PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
 
 #define PYTHON_API_VERSION 1012
 #define PYTHON_API_STRING "1012"
@@ -84,9 +84,9 @@
 #define Py_InitModule4 Py_InitModule4TraceRefs
 #endif
 
-PyAPI_FUNC(PyObject *) Py_InitModule4(char *name, PyMethodDef *methods,
-                                            char *doc, PyObject *self,
-                                            int apiver);
+PyAPI_FUNC(PyObject *) Py_InitModule4(const char *name, PyMethodDef *methods,
+                                      const char *doc, PyObject *self,
+                                      int apiver);
 
 #define Py_InitModule(name, methods) \
 	Py_InitModule4(name, methods, (char *)NULL, (PyObject *)NULL, \
diff --git a/Include/moduleobject.h b/Include/moduleobject.h
index 0f67da3..3d278af 100644
--- a/Include/moduleobject.h
+++ b/Include/moduleobject.h
@@ -12,7 +12,7 @@
 #define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type)
 #define PyModule_CheckExact(op) ((op)->ob_type == &PyModule_Type)
 
-PyAPI_FUNC(PyObject *) PyModule_New(char *);
+PyAPI_FUNC(PyObject *) PyModule_New(const char *);
 PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
 PyAPI_FUNC(char *) PyModule_GetName(PyObject *);
 PyAPI_FUNC(char *) PyModule_GetFilename(PyObject *);
diff --git a/Include/object.h b/Include/object.h
index 15fee96..ed6f3d1 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -225,9 +225,9 @@
 typedef void (*freefunc)(void *);
 typedef void (*destructor)(PyObject *);
 typedef int (*printfunc)(PyObject *, FILE *, int);
-typedef PyObject *(*getattrfunc)(PyObject *, char *);
+typedef PyObject *(*getattrfunc)(PyObject *, const char *);
 typedef PyObject *(*getattrofunc)(PyObject *, PyObject *);
-typedef int (*setattrfunc)(PyObject *, char *, PyObject *);
+typedef int (*setattrfunc)(PyObject *, const char *, PyObject *);
 typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *);
 typedef int (*cmpfunc)(PyObject *, PyObject *);
 typedef PyObject *(*reprfunc)(PyObject *);
@@ -243,7 +243,7 @@
 
 typedef struct _typeobject {
 	PyObject_VAR_HEAD
-	char *tp_name; /* For printing, in format "<module>.<name>" */
+	const char *tp_name; /* For printing, in format "<module>.<name>" */
 	int tp_basicsize, tp_itemsize; /* For allocation */
 
 	/* Methods to implement standard operations */
@@ -275,7 +275,7 @@
 	/* Flags to define presence of optional/expanded features */
 	long tp_flags;
 
-	char *tp_doc; /* Documentation string */
+	const char *tp_doc; /* Documentation string */
 
 	/* Assigned meaning in release 2.0 */
 	/* call function for all accessible objects */
@@ -379,9 +379,9 @@
 PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *);
 PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);
 PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int);
-PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, char *);
-PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, char *, PyObject *);
-PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, char *);
+PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *);
+PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *);
+PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *);
 PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *);
 PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
 PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *);