[Python-checkins] cpython: Issue #25923: Added more const qualifiers to signatures of static and private

serhiy.storchaka python-checkins at python.org
Fri Dec 25 13:02:32 EST 2015


https://hg.python.org/cpython/rev/80d1faa9735d
changeset:   99675:80d1faa9735d
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Fri Dec 25 20:01:53 2015 +0200
summary:
  Issue #25923: Added more const qualifiers to signatures of static and private functions.

files:
  Include/bytes_methods.h     |   6 +-
  Include/pythonrun.h         |   8 +-
  Misc/coverity_model.c       |   2 +-
  Modules/_ctypes/_ctypes.c   |   4 +-
  Modules/_ctypes/callbacks.c |   2 +-
  Modules/_ctypes/callproc.c  |   2 +-
  Modules/_ctypes/ctypes.h    |   2 +-
  Modules/_curses_panel.c     |   2 +-
  Modules/_datetimemodule.c   |   2 +-
  Modules/_io/_iomodule.h     |   2 +-
  Modules/_io/bufferedio.c    |   2 +-
  Modules/_io/fileio.c        |   4 +-
  Modules/_io/textio.c        |  20 ++++----
  Modules/_json.c             |   4 +-
  Modules/_localemodule.c     |   2 +-
  Modules/_pickle.c           |   2 +-
  Modules/_posixsubprocess.c  |   2 +-
  Modules/_scproxy.c          |   2 +-
  Modules/_sre.c              |   2 +-
  Modules/_ssl.c              |   4 +-
  Modules/_struct.c           |   6 +-
  Modules/_testmultiphase.c   |   2 +-
  Modules/_tkinter.c          |   8 +-
  Modules/_winapi.c           |   4 +-
  Modules/binascii.c          |  44 +++++++++++-------
  Modules/gcmodule.c          |   2 +-
  Modules/getaddrinfo.c       |   2 +-
  Modules/main.c              |   2 +-
  Modules/mathmodule.c        |   4 +-
  Modules/parsermodule.c      |  10 ++--
  Modules/posixmodule.c       |  43 ++++++++++-------
  Modules/pyexpat.c           |   6 +-
  Modules/socketmodule.c      |   4 +-
  Modules/timemodule.c        |   2 +-
  Modules/xxlimited.c         |   2 +-
  Modules/xxmodule.c          |   2 +-
  Modules/zipimport.c         |   2 +-
  Modules/zlibmodule.c        |   2 +-
  Objects/bytearrayobject.c   |   8 +-
  Objects/bytes_methods.c     |   6 +-
  Objects/bytesobject.c       |   2 +-
  Objects/descrobject.c       |   2 +-
  Objects/dictobject.c        |   2 +-
  Objects/memoryobject.c      |   4 +-
  Objects/typeobject.c        |  10 ++--
  Objects/unicodeobject.c     |   6 +-
  Objects/weakrefobject.c     |   2 +-
  Parser/pgen.c               |   4 +-
  Parser/pgenmain.c           |   4 +-
  Parser/tokenizer.c          |   6 +-
  Python/_warnings.c          |   2 +-
  Python/ceval.c              |   4 +-
  Python/dtoa.c               |   2 +-
  Python/dynload_win.c        |   2 +-
  Python/getargs.c            |  58 ++++++++++++------------
  Python/marshal.c            |  34 +++++++------
  Python/modsupport.c         |   4 +-
  Python/pylifecycle.c        |   4 +-
  Python/pythonrun.c          |   8 +-
  Python/symtable.c           |   4 +-
  60 files changed, 210 insertions(+), 191 deletions(-)


diff --git a/Include/bytes_methods.h b/Include/bytes_methods.h
--- a/Include/bytes_methods.h
+++ b/Include/bytes_methods.h
@@ -17,9 +17,9 @@
 /* These store their len sized answer in the given preallocated *result arg. */
 extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len);
 extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len);
-extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len);
-extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len);
-extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len);
+extern void _Py_bytes_title(char *result, const char *s, Py_ssize_t len);
+extern void _Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len);
+extern void _Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len);
 
 /* The maketrans() static method. */
 extern PyObject* _Py_bytes_maketrans(Py_buffer *frm, Py_buffer *to);
diff --git a/Include/pythonrun.h b/Include/pythonrun.h
--- a/Include/pythonrun.h
+++ b/Include/pythonrun.h
@@ -66,8 +66,8 @@
     const char *filename,       /* decoded from the filesystem encoding */
     const char* enc,
     int start,
-    char *ps1,
-    char *ps2,
+    const char *ps1,
+    const char *ps2,
     PyCompilerFlags *flags,
     int *errcode,
     PyArena *arena);
@@ -76,8 +76,8 @@
     PyObject *filename,
     const char* enc,
     int start,
-    char *ps1,
-    char *ps2,
+    const char *ps1,
+    const char *ps2,
     PyCompilerFlags *flags,
     int *errcode,
     PyArena *arena);
diff --git a/Misc/coverity_model.c b/Misc/coverity_model.c
--- a/Misc/coverity_model.c
+++ b/Misc/coverity_model.c
@@ -94,7 +94,7 @@
 }
 
 /* Parser/pgenmain.c */
-grammar *getgrammar(char *filename)
+grammar *getgrammar(const char *filename)
 {
     grammar *g;
     __coverity_tainted_data_sink__(filename);
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -3195,7 +3195,7 @@
 }
 
 static int
-_get_name(PyObject *obj, char **pname)
+_get_name(PyObject *obj, const char **pname)
 {
 #ifdef MS_WIN32
     if (PyLong_Check(obj)) {
@@ -3223,7 +3223,7 @@
 static PyObject *
 PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-    char *name;
+    const char *name;
     int (* address)(void);
     PyObject *ftuple;
     PyObject *dll;
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -77,7 +77,7 @@
 /**************************************************************/
 
 static void
-PrintError(char *msg, ...)
+PrintError(const char *msg, ...)
 {
     char buf[512];
     PyObject *f = PySys_GetObject("stderr");
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -928,7 +928,7 @@
  * Raise a new exception 'exc_class', adding additional text to the original
  * exception string.
  */
-void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...)
+void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...)
 {
     va_list vargs;
     PyObject *tp, *v, *tb, *s, *cls_str, *msg_str;
diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h
--- a/Modules/_ctypes/ctypes.h
+++ b/Modules/_ctypes/ctypes.h
@@ -327,7 +327,7 @@
 PyCData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
           Py_ssize_t index, Py_ssize_t size, char *ptr);
 
-extern void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...);
+extern void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...);
 
 struct basespec {
     CDataObject *base;
diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c
--- a/Modules/_curses_panel.c
+++ b/Modules/_curses_panel.c
@@ -56,7 +56,7 @@
  */
 
 static PyObject *
-PyCursesCheckERR(int code, char *fname)
+PyCursesCheckERR(int code, const char *fname)
 {
     if (code != ERR) {
         Py_INCREF(Py_None);
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -873,7 +873,7 @@
  * this returns NULL.  Else result is returned.
  */
 static PyObject *
-call_tzinfo_method(PyObject *tzinfo, char *name, PyObject *tzinfoarg)
+call_tzinfo_method(PyObject *tzinfo, const char *name, PyObject *tzinfoarg)
 {
     PyObject *offset;
 
diff --git a/Modules/_io/_iomodule.h b/Modules/_io/_iomodule.h
--- a/Modules/_io/_iomodule.h
+++ b/Modules/_io/_iomodule.h
@@ -60,7 +60,7 @@
    * Otherwise, the line ending is specified by readnl, a str object */
 extern Py_ssize_t _PyIO_find_line_ending(
     int translated, int universal, PyObject *readnl,
-    int kind, char *start, char *end, Py_ssize_t *consumed);
+    int kind, const char *start, const char *end, Py_ssize_t *consumed);
 
 /* Return 1 if an EnvironmentError with errno == EINTR is set (and then
    clears the error indicator), 0 otherwise.
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -659,7 +659,7 @@
 
 /* Sets the current error to BlockingIOError */
 static void
-_set_BlockingIOError(char *msg, Py_ssize_t written)
+_set_BlockingIOError(const char *msg, Py_ssize_t written)
 {
     PyObject *err;
     PyErr_Clear();
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -540,7 +540,7 @@
 }
 
 static PyObject *
-err_mode(char *action)
+err_mode(const char *action)
 {
     _PyIO_State *state = IO_STATE();
     if (state != NULL)
@@ -1043,7 +1043,7 @@
 }
 #endif /* HAVE_FTRUNCATE */
 
-static char *
+static const char *
 mode_string(fileio *self)
 {
     if (self->created) {
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -1648,8 +1648,8 @@
 /* NOTE: `end` must point to the real end of the Py_UCS4 storage,
    that is to the NUL character. Otherwise the function will produce
    incorrect results. */
-static char *
-find_control_char(int kind, char *s, char *end, Py_UCS4 ch)
+static const char *
+find_control_char(int kind, const char *s, const char *end, Py_UCS4 ch)
 {
     if (kind == PyUnicode_1BYTE_KIND) {
         assert(ch < 256);
@@ -1669,13 +1669,13 @@
 Py_ssize_t
 _PyIO_find_line_ending(
     int translated, int universal, PyObject *readnl,
-    int kind, char *start, char *end, Py_ssize_t *consumed)
+    int kind, const char *start, const char *end, Py_ssize_t *consumed)
 {
     Py_ssize_t len = ((char*)end - (char*)start)/kind;
 
     if (translated) {
         /* Newlines are already translated, only search for \n */
-        char *pos = find_control_char(kind, start, end, '\n');
+        const char *pos = find_control_char(kind, start, end, '\n');
         if (pos != NULL)
             return (pos - start)/kind + 1;
         else {
@@ -1687,7 +1687,7 @@
         /* Universal newline search. Find any of \r, \r\n, \n
          * The decoder ensures that \r\n are not split in two pieces
          */
-        char *s = start;
+        const char *s = start;
         for (;;) {
             Py_UCS4 ch;
             /* Fast path for non-control chars. The loop always ends
@@ -1717,21 +1717,21 @@
         /* Assume that readnl is an ASCII character. */
         assert(PyUnicode_KIND(readnl) == PyUnicode_1BYTE_KIND);
         if (readnl_len == 1) {
-            char *pos = find_control_char(kind, start, end, nl[0]);
+            const char *pos = find_control_char(kind, start, end, nl[0]);
             if (pos != NULL)
                 return (pos - start)/kind + 1;
             *consumed = len;
             return -1;
         }
         else {
-            char *s = start;
-            char *e = end - (readnl_len - 1)*kind;
-            char *pos;
+            const char *s = start;
+            const char *e = end - (readnl_len - 1)*kind;
+            const char *pos;
             if (e < s)
                 e = s;
             while (s < e) {
                 Py_ssize_t i;
-                char *pos = find_control_char(kind, s, end, nl[0]);
+                const char *pos = find_control_char(kind, s, end, nl[0]);
                 if (pos == NULL || pos >= e)
                     break;
                 for (i = 1; i < readnl_len; i++) {
diff --git a/Modules/_json.c b/Modules/_json.c
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -112,7 +112,7 @@
 static PyObject *
 _encoded_const(PyObject *obj);
 static void
-raise_errmsg(char *msg, PyObject *s, Py_ssize_t end);
+raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end);
 static PyObject *
 encoder_encode_string(PyEncoderObject *s, PyObject *obj);
 static PyObject *
@@ -323,7 +323,7 @@
 }
 
 static void
-raise_errmsg(char *msg, PyObject *s, Py_ssize_t end)
+raise_errmsg(const char *msg, PyObject *s, Py_ssize_t end)
 {
     /* Use JSONDecodeError exception to raise a nice looking ValueError subclass */
     static PyObject *JSONDecodeError = NULL;
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -49,7 +49,7 @@
 
 /* the grouping is terminated by either 0 or CHAR_MAX */
 static PyObject*
-copy_grouping(char* s)
+copy_grouping(const char* s)
 {
     int i;
     PyObject *result, *val = NULL;
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2187,7 +2187,7 @@
 }
 
 static int
-write_utf8(PicklerObject *self, char *data, Py_ssize_t size)
+write_utf8(PicklerObject *self, const char *data, Py_ssize_t size)
 {
     char header[9];
     Py_ssize_t len;
diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c
--- a/Modules/_posixsubprocess.c
+++ b/Modules/_posixsubprocess.c
@@ -72,7 +72,7 @@
 
 /* Convert ASCII to a positive int, no libc call. no overflow. -1 on error. */
 static int
-_pos_int_from_ascii(char *name)
+_pos_int_from_ascii(const char *name)
 {
     int num = 0;
     while (*name >= '0' && *name <= '9') {
diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c
--- a/Modules/_scproxy.c
+++ b/Modules/_scproxy.c
@@ -130,7 +130,7 @@
 }
 
 static int
-set_proxy(PyObject* proxies, char* proto, CFDictionaryRef proxyDict,
+set_proxy(PyObject* proxies, const char* proto, CFDictionaryRef proxyDict,
                 CFStringRef enabledKey,
                 CFStringRef hostKey, CFStringRef portKey)
 {
diff --git a/Modules/_sre.c b/Modules/_sre.c
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -714,7 +714,7 @@
 }
 
 static PyObject*
-call(char* module, char* function, PyObject* args)
+call(const char* module, const char* function, PyObject* args)
 {
     PyObject* name;
     PyObject* mod;
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -378,7 +378,7 @@
 }
 
 static PyObject *
-PySSL_SetError(PySSLSocket *obj, int ret, char *filename, int lineno)
+PySSL_SetError(PySSLSocket *obj, int ret, const char *filename, int lineno)
 {
     PyObject *type = PySSLErrorObject;
     char *errstr = NULL;
@@ -460,7 +460,7 @@
 }
 
 static PyObject *
-_setSSLError (char *errstr, int errcode, char *filename, int lineno) {
+_setSSLError (const char *errstr, int errcode, const char *filename, int lineno) {
 
     if (errstr == NULL)
         errcode = ERR_peek_last_error();
diff --git a/Modules/_struct.c b/Modules/_struct.c
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -1189,7 +1189,7 @@
 
 
 static const formatdef *
-whichtable(char **pfmt)
+whichtable(const char **pfmt)
 {
     const char *fmt = (*pfmt)++; /* May be backed out of later */
     switch (*fmt) {
@@ -1268,7 +1268,7 @@
 
     fmt = PyBytes_AS_STRING(self->s_format);
 
-    f = whichtable((char **)&fmt);
+    f = whichtable(&fmt);
 
     s = fmt;
     size = 0;
@@ -1457,7 +1457,7 @@
 }
 
 static PyObject *
-s_unpack_internal(PyStructObject *soself, char *startfrom) {
+s_unpack_internal(PyStructObject *soself, const char *startfrom) {
     formatcode *code;
     Py_ssize_t i = 0;
     PyObject *result = PyTuple_New(soself->s_len);
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c
--- a/Modules/_testmultiphase.c
+++ b/Modules/_testmultiphase.c
@@ -61,7 +61,7 @@
 }
 
 static int
-Example_setattr(ExampleObject *self, char *name, PyObject *v)
+Example_setattr(ExampleObject *self, const char *name, PyObject *v)
 {
     if (self->x_attr == NULL) {
         self->x_attr = PyDict_New();
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -841,7 +841,7 @@
     Py_DECREF(tp);
 }
 
-static char*
+static const char *
 PyTclObject_TclString(PyObject *self)
 {
     return Tcl_GetString(((PyTclObject*)self)->value);
@@ -1726,7 +1726,7 @@
 varname_converter(PyObject *in, void *_out)
 {
     char *s;
-    char **out = (char**)_out;
+    const char **out = (const char**)_out;
     if (PyBytes_Check(in)) {
         if (PyBytes_Size(in) > INT_MAX) {
             PyErr_SetString(PyExc_OverflowError, "bytes object is too long");
@@ -1846,7 +1846,7 @@
 static PyObject *
 SetVar(PyObject *self, PyObject *args, int flags)
 {
-    char *name1, *name2;
+    const char *name1, *name2;
     PyObject *newValue;
     PyObject *res = NULL;
     Tcl_Obj *newval, *ok;
@@ -1915,7 +1915,7 @@
 static PyObject *
 GetVar(PyObject *self, PyObject *args, int flags)
 {
-    char *name1, *name2=NULL;
+    const char *name1, *name2=NULL;
     PyObject *res = NULL;
     Tcl_Obj *tres;
 
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -675,7 +675,7 @@
 /* helpers for createprocess */
 
 static unsigned long
-getulong(PyObject* obj, char* name)
+getulong(PyObject* obj, const char* name)
 {
     PyObject* value;
     unsigned long ret;
@@ -691,7 +691,7 @@
 }
 
 static HANDLE
-gethandle(PyObject* obj, char* name)
+gethandle(PyObject* obj, const char* name)
 {
     PyObject* value;
     HANDLE ret;
diff --git a/Modules/binascii.c b/Modules/binascii.c
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -256,7 +256,8 @@
 binascii_a2b_uu_impl(PyModuleDef *module, Py_buffer *data)
 /*[clinic end generated code: output=5779f39b0b48459f input=7cafeaf73df63d1c]*/
 {
-    unsigned char *ascii_data, *bin_data;
+    const unsigned char *ascii_data;
+    unsigned char *bin_data;
     int leftbits = 0;
     unsigned char this_ch;
     unsigned int leftchar = 0;
@@ -342,7 +343,8 @@
 binascii_b2a_uu_impl(PyModuleDef *module, Py_buffer *data)
 /*[clinic end generated code: output=181021b69bb9a414 input=00fdf458ce8b465b]*/
 {
-    unsigned char *ascii_data, *bin_data;
+    unsigned char *ascii_data;
+    const unsigned char *bin_data;
     int leftbits = 0;
     unsigned char this_ch;
     unsigned int leftchar = 0;
@@ -389,7 +391,7 @@
 
 
 static int
-binascii_find_valid(unsigned char *s, Py_ssize_t slen, int num)
+binascii_find_valid(const unsigned char *s, Py_ssize_t slen, int num)
 {
     /* Finds & returns the (num+1)th
     ** valid character for base64, or -1 if none.
@@ -426,7 +428,8 @@
 binascii_a2b_base64_impl(PyModuleDef *module, Py_buffer *data)
 /*[clinic end generated code: output=3e351b702bed56d2 input=5872acf6e1cac243]*/
 {
-    unsigned char *ascii_data, *bin_data;
+    const unsigned char *ascii_data;
+    unsigned char *bin_data;
     int leftbits = 0;
     unsigned char this_ch;
     unsigned int leftchar = 0;
@@ -522,7 +525,8 @@
 binascii_b2a_base64_impl(PyModuleDef *module, Py_buffer *data, int newline)
 /*[clinic end generated code: output=19e1dd719a890b50 input=7b2ea6fa38d8924c]*/
 {
-    unsigned char *ascii_data, *bin_data;
+    unsigned char *ascii_data;
+    const unsigned char *bin_data;
     int leftbits = 0;
     unsigned char this_ch;
     unsigned int leftchar = 0;
@@ -589,7 +593,8 @@
 binascii_a2b_hqx_impl(PyModuleDef *module, Py_buffer *data)
 /*[clinic end generated code: output=60bcdbbd28b105cd input=0d914c680e0eed55]*/
 {
-    unsigned char *ascii_data, *bin_data;
+    const unsigned char *ascii_data;
+    unsigned char *bin_data;
     int leftbits = 0;
     unsigned char this_ch;
     unsigned int leftchar = 0;
@@ -667,7 +672,8 @@
 binascii_rlecode_hqx_impl(PyModuleDef *module, Py_buffer *data)
 /*[clinic end generated code: output=0905da344dbf0648 input=e1f1712447a82b09]*/
 {
-    unsigned char *in_data, *out_data;
+    const unsigned char *in_data;
+    unsigned char *out_data;
     unsigned char ch;
     Py_ssize_t in, inend, len;
     _PyBytesWriter writer;
@@ -728,7 +734,8 @@
 binascii_b2a_hqx_impl(PyModuleDef *module, Py_buffer *data)
 /*[clinic end generated code: output=5a987810d5e3cdbb input=9596ebe019fe12ba]*/
 {
-    unsigned char *ascii_data, *bin_data;
+    unsigned char *ascii_data;
+    const unsigned char *bin_data;
     int leftbits = 0;
     unsigned char this_ch;
     unsigned int leftchar = 0;
@@ -782,7 +789,8 @@
 binascii_rledecode_hqx_impl(PyModuleDef *module, Py_buffer *data)
 /*[clinic end generated code: output=f7afd89b789946ab input=54cdd49fc014402c]*/
 {
-    unsigned char *in_data, *out_data;
+    const unsigned char *in_data;
+    unsigned char *out_data;
     unsigned char in_byte, in_repeat;
     Py_ssize_t in_len;
     _PyBytesWriter writer;
@@ -899,7 +907,7 @@
 binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc)
 /*[clinic end generated code: output=167c2dac62625717 input=add8c53712ccceda]*/
 {
-    unsigned char *bin_data;
+    const unsigned char *bin_data;
     Py_ssize_t len;
 
     crc &= 0xffff;
@@ -1050,7 +1058,7 @@
 #ifdef USE_ZLIB_CRC32
 /* This was taken from zlibmodule.c PyZlib_crc32 (but is PY_SSIZE_T_CLEAN) */
 {
-    Byte *buf;
+    const Byte *buf;
     Py_ssize_t len;
     int signed_val;
 
@@ -1061,7 +1069,7 @@
 }
 #else  /* USE_ZLIB_CRC32 */
 { /* By Jim Ahlstrom; All rights transferred to CNRI */
-    unsigned char *bin_data;
+    const unsigned char *bin_data;
     Py_ssize_t len;
     unsigned int result;
 
@@ -1144,7 +1152,7 @@
 binascii_a2b_hex_impl(PyModuleDef *module, Py_buffer *hexstr)
 /*[clinic end generated code: output=d61da452b5c6d290 input=9e1e7f2f94db24fd]*/
 {
-    char* argbuf;
+    const char* argbuf;
     Py_ssize_t arglen;
     PyObject *retval;
     char* retbuf;
@@ -1232,7 +1240,8 @@
 {
     Py_ssize_t in, out;
     char ch;
-    unsigned char *ascii_data, *odata;
+    const unsigned char *ascii_data;
+    unsigned char *odata;
     Py_ssize_t datalen = 0;
     PyObject *rv;
 
@@ -1338,13 +1347,14 @@
 /*[clinic end generated code: output=a87ca9ccb94e2a9f input=7f2a9aaa008e92b2]*/
 {
     Py_ssize_t in, out;
-    unsigned char *databuf, *odata;
+    const unsigned char *databuf;
+    unsigned char *odata;
     Py_ssize_t datalen = 0, odatalen = 0;
     PyObject *rv;
     unsigned int linelen = 0;
     unsigned char ch;
     int crlf = 0;
-    unsigned char *p;
+    const unsigned char *p;
 
     databuf = data->buf;
     datalen = data->len;
@@ -1353,7 +1363,7 @@
     /* XXX: this function has the side effect of converting all of
      * the end of lines to be the same depending on this detection
      * here */
-    p = (unsigned char *) memchr(databuf, '\n', datalen);
+    p = (const unsigned char *) memchr(databuf, '\n', datalen);
     if ((p != NULL) && (p > databuf) && (*(p-1) == '\r'))
         crlf = 1;
 
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -738,7 +738,7 @@
 }
 
 static void
-debug_cycle(char *msg, PyObject *op)
+debug_cycle(const char *msg, PyObject *op)
 {
     PySys_FormatStderr("gc: %s <%s %p>\n",
                        msg, Py_TYPE(op)->tp_name, op);
diff --git a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c
--- a/Modules/getaddrinfo.c
+++ b/Modules/getaddrinfo.c
@@ -198,7 +198,7 @@
 
 #define ERR(err) { error = (err); goto bad; }
 
-char *
+const char *
 gai_strerror(int ecode)
 {
     if (ecode < 0 || ecode > EAI_MAX)
diff --git a/Modules/main.c b/Modules/main.c
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -103,7 +103,7 @@
 ";
 
 static int
-usage(int exitcode, wchar_t* program)
+usage(int exitcode, const wchar_t* program)
 {
     FILE *f = exitcode ? stderr : stdout;
 
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -876,7 +876,7 @@
 }
 
 static PyObject *
-math_2(PyObject *args, double (*func) (double, double), char *funcname)
+math_2(PyObject *args, double (*func) (double, double), const char *funcname)
 {
     PyObject *ox, *oy;
     double x, y, r;
@@ -1673,7 +1673,7 @@
    in that int is larger than PY_SSIZE_T_MAX. */
 
 static PyObject*
-loghelper(PyObject* arg, double (*func)(double), char *funcname)
+loghelper(PyObject* arg, double (*func)(double), const char *funcname)
 {
     /* If it is int, do it ourselves. */
     if (PyLong_Check(arg)) {
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -578,13 +578,13 @@
 }
 
 
-/*  err_string(char* message)
+/*  err_string(const char* message)
  *
  *  Sets the error string for an exception of type ParserError.
  *
  */
 static void
-err_string(char *message)
+err_string(const char *message)
 {
     PyErr_SetString(parser_error, message);
 }
@@ -597,7 +597,7 @@
  *
  */
 static PyObject*
-parser_do_parse(PyObject *args, PyObject *kw, char *argspec, int type)
+parser_do_parse(PyObject *args, PyObject *kw, const char *argspec, int type)
 {
     char*     string = 0;
     PyObject* res    = 0;
@@ -984,7 +984,7 @@
 /*
  *  Validation routines used within the validation section:
  */
-static int validate_terminal(node *terminal, int type, char *string);
+static int validate_terminal(node *terminal, int type, const char *string);
 
 #define validate_ampersand(ch)  validate_terminal(ch,      AMPER, "&")
 #define validate_circumflex(ch) validate_terminal(ch, CIRCUMFLEX, "^")
@@ -1082,7 +1082,7 @@
 
 
 static int
-validate_terminal(node *terminal, int type, char *string)
+validate_terminal(node *terminal, int type, const char *string)
 {
     int res = (validate_ntype(terminal, type)
                && ((string == 0) || (strcmp(string, STR(terminal)) == 0)));
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -949,7 +949,8 @@
 }
 
 static void
-argument_unavailable_error(char *function_name, char *argument_name) {
+argument_unavailable_error(const char *function_name, const char *argument_name)
+{
     PyErr_Format(PyExc_NotImplementedError,
         "%s%s%s unavailable on this platform",
         (function_name != NULL) ? function_name : "",
@@ -972,7 +973,8 @@
 }
 
 static int
-fd_specified(char *function_name, int fd) {
+fd_specified(const char *function_name, int fd)
+{
     if (fd == -1)
         return 0;
 
@@ -981,7 +983,8 @@
 }
 
 static int
-follow_symlinks_specified(char *function_name, int follow_symlinks) {
+follow_symlinks_specified(const char *function_name, int follow_symlinks)
+{
     if (follow_symlinks)
         return 0;
 
@@ -990,7 +993,8 @@
 }
 
 static int
-path_and_dir_fd_invalid(char *function_name, path_t *path, int dir_fd) {
+path_and_dir_fd_invalid(const char *function_name, path_t *path, int dir_fd)
+{
     if (!path->narrow && !path->wide && (dir_fd != DEFAULT_DIR_FD)) {
         PyErr_Format(PyExc_ValueError,
                      "%s: can't specify dir_fd without matching path",
@@ -1001,7 +1005,8 @@
 }
 
 static int
-dir_fd_and_fd_invalid(char *function_name, int dir_fd, int fd) {
+dir_fd_and_fd_invalid(const char *function_name, int dir_fd, int fd)
+{
     if ((dir_fd != DEFAULT_DIR_FD) && (fd != -1)) {
         PyErr_Format(PyExc_ValueError,
                      "%s: can't specify both dir_fd and fd",
@@ -1012,8 +1017,9 @@
 }
 
 static int
-fd_and_follow_symlinks_invalid(char *function_name, int fd,
-                               int follow_symlinks) {
+fd_and_follow_symlinks_invalid(const char *function_name, int fd,
+                               int follow_symlinks)
+{
     if ((fd > 0) && (!follow_symlinks)) {
         PyErr_Format(PyExc_ValueError,
                      "%s: cannot use fd and follow_symlinks together",
@@ -1024,8 +1030,9 @@
 }
 
 static int
-dir_fd_and_follow_symlinks_invalid(char *function_name, int dir_fd,
-                                   int follow_symlinks) {
+dir_fd_and_follow_symlinks_invalid(const char *function_name, int dir_fd,
+                                   int follow_symlinks)
+{
     if ((dir_fd != DEFAULT_DIR_FD) && (!follow_symlinks)) {
         PyErr_Format(PyExc_ValueError,
                      "%s: cannot use dir_fd and follow_symlinks together",
@@ -1220,7 +1227,7 @@
 
 #ifdef MS_WINDOWS
 static PyObject *
-win32_error(char* function, const char* filename)
+win32_error(const char* function, const char* filename)
 {
     /* XXX We should pass the function name along in the future.
        (winreg.c also wants to pass the function name.)
@@ -1235,7 +1242,7 @@
 }
 
 static PyObject *
-win32_error_object(char* function, PyObject* filename)
+win32_error_object(const char* function, PyObject* filename)
 {
     /* XXX - see win32_error for comments on 'function' */
     errno = GetLastError();
@@ -2100,7 +2107,7 @@
 
 
 static PyObject *
-posix_do_stat(char *function_name, path_t *path,
+posix_do_stat(const char *function_name, path_t *path,
               int dir_fd, int follow_symlinks)
 {
     STRUCT_STAT st;
@@ -4561,7 +4568,7 @@
 #if defined(HAVE_FUTIMESAT) || defined(HAVE_UTIMENSAT)
 
 static int
-utime_dir_fd(utime_t *ut, int dir_fd, char *path, int follow_symlinks)
+utime_dir_fd(utime_t *ut, int dir_fd, const char *path, int follow_symlinks)
 {
 #ifdef HAVE_UTIMENSAT
     int flags = follow_symlinks ? 0 : AT_SYMLINK_NOFOLLOW;
@@ -4610,7 +4617,7 @@
 #ifdef UTIME_HAVE_NOFOLLOW_SYMLINKS
 
 static int
-utime_nofollow_symlinks(utime_t *ut, char *path)
+utime_nofollow_symlinks(utime_t *ut, const char *path)
 {
 #ifdef HAVE_UTIMENSAT
     UTIME_TO_TIMESPEC;
@@ -4626,7 +4633,7 @@
 #ifndef MS_WINDOWS
 
 static int
-utime_default(utime_t *ut, char *path)
+utime_default(utime_t *ut, const char *path)
 {
 #ifdef HAVE_UTIMENSAT
     UTIME_TO_TIMESPEC;
@@ -7323,7 +7330,7 @@
 
 /* Return True if the path at src relative to dest is a directory */
 static int
-_check_dirA(char *src, char *dest)
+_check_dirA(const char *src, char *dest)
 {
     WIN32_FILE_ATTRIBUTE_DATA src_info;
     char dest_parent[MAX_PATH];
@@ -11835,7 +11842,7 @@
 #else /* POSIX */
 
 static char *
-join_path_filename(char *path_narrow, char* filename, Py_ssize_t filename_len)
+join_path_filename(const char *path_narrow, const char* filename, Py_ssize_t filename_len)
 {
     Py_ssize_t path_len;
     Py_ssize_t size;
@@ -11867,7 +11874,7 @@
 }
 
 static PyObject *
-DirEntry_from_posix_info(path_t *path, char *name, Py_ssize_t name_len,
+DirEntry_from_posix_info(path_t *path, const char *name, Py_ssize_t name_len,
                          ino_t d_ino
 #ifdef HAVE_DIRENT_D_TYPE
                          , unsigned char d_type
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -91,7 +91,7 @@
  * false on an exception.
  */
 static int
-set_error_attr(PyObject *err, char *name, int value)
+set_error_attr(PyObject *err, const char *name, int value)
 {
     PyObject *v = PyLong_FromLong(value);
 
@@ -218,7 +218,7 @@
 }
 
 static PyObject*
-call_with_frame(char *funcname, int lineno, PyObject* func, PyObject* args,
+call_with_frame(const char *funcname, int lineno, PyObject* func, PyObject* args,
                 xmlparseobject *self)
 {
     PyObject *res;
@@ -766,7 +766,7 @@
 {
     PyObject *str;
     Py_ssize_t len;
-    char *ptr;
+    const char *ptr;
 
     str = PyObject_CallFunction(meth, "n", buf_size);
     if (str == NULL)
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -904,7 +904,7 @@
    an error occurred; then an exception is raised. */
 
 static int
-setipaddr(char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int af)
+setipaddr(const char *name, struct sockaddr *addr_ret, size_t addr_ret_size, int af)
 {
     struct addrinfo hints, *res;
     int error;
@@ -1085,7 +1085,7 @@
    an error occurred. */
 
 static int
-setbdaddr(char *name, bdaddr_t *bdaddr)
+setbdaddr(const char *name, bdaddr_t *bdaddr)
 {
     unsigned int b0, b1, b2, b3, b4, b5;
     char ch;
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -311,7 +311,7 @@
    Returns non-zero on success (parallels PyArg_ParseTuple).
 */
 static int
-parse_time_t_args(PyObject *args, char *format, time_t *pwhen)
+parse_time_t_args(PyObject *args, const char *format, time_t *pwhen)
 {
     PyObject *ot = NULL;
     time_t whent;
diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c
--- a/Modules/xxlimited.c
+++ b/Modules/xxlimited.c
@@ -89,7 +89,7 @@
 }
 
 static int
-Xxo_setattr(XxoObject *self, char *name, PyObject *v)
+Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
 {
     if (self->x_attr == NULL) {
         self->x_attr = PyDict_New();
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
--- a/Modules/xxmodule.c
+++ b/Modules/xxmodule.c
@@ -76,7 +76,7 @@
 }
 
 static int
-Xxo_setattr(XxoObject *self, char *name, PyObject *v)
+Xxo_setattr(XxoObject *self, const char *name, PyObject *v)
 {
     if (self->x_attr == NULL) {
         self->x_attr = PyDict_New();
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -815,7 +815,7 @@
    4 bytes, encoded as little endian. This partially reimplements
    marshal.c:r_long() */
 static long
-get_long(unsigned char *buf) {
+get_long(const unsigned char *buf) {
     long x;
     x =  buf[0];
     x |= (long)buf[1] <<  8;
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -53,7 +53,7 @@
 } compobject;
 
 static void
-zlib_error(z_stream zst, int err, char *msg)
+zlib_error(z_stream zst, int err, const char *msg)
 {
     const char *zmsg = Z_NULL;
     /* In case of a version mismatch, zst.msg won't be initialized.
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2576,8 +2576,8 @@
 /* XXX These two helpers could be optimized if argsize == 1 */
 
 static Py_ssize_t
-lstrip_helper(char *myptr, Py_ssize_t mysize,
-              void *argptr, Py_ssize_t argsize)
+lstrip_helper(const char *myptr, Py_ssize_t mysize,
+              const void *argptr, Py_ssize_t argsize)
 {
     Py_ssize_t i = 0;
     while (i < mysize && memchr(argptr, (unsigned char) myptr[i], argsize))
@@ -2586,8 +2586,8 @@
 }
 
 static Py_ssize_t
-rstrip_helper(char *myptr, Py_ssize_t mysize,
-              void *argptr, Py_ssize_t argsize)
+rstrip_helper(const char *myptr, Py_ssize_t mysize,
+              const void *argptr, Py_ssize_t argsize)
 {
     Py_ssize_t i = mysize - 1;
     while (i >= 0 && memchr(argptr, (unsigned char) myptr[i], argsize))
diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c
--- a/Objects/bytes_methods.c
+++ b/Objects/bytes_methods.c
@@ -277,7 +277,7 @@
 characters, all remaining cased characters have lowercase.");
 
 void
-_Py_bytes_title(char *result, char *s, Py_ssize_t len)
+_Py_bytes_title(char *result, const char *s, Py_ssize_t len)
 {
     Py_ssize_t i;
     int previous_is_cased = 0;
@@ -306,7 +306,7 @@
 and the rest lower-cased.");
 
 void
-_Py_bytes_capitalize(char *result, char *s, Py_ssize_t len)
+_Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len)
 {
     Py_ssize_t i;
 
@@ -336,7 +336,7 @@
 to lowercase ASCII and vice versa.");
 
 void
-_Py_bytes_swapcase(char *result, char *s, Py_ssize_t len)
+_Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len)
 {
     Py_ssize_t i;
 
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -308,7 +308,7 @@
         {
             Py_ssize_t i;
 
-            p = va_arg(vargs, char*);
+            p = va_arg(vargs, const char*);
             i = strlen(p);
             if (prec > 0 && i > prec)
                 i = prec;
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -22,7 +22,7 @@
 }
 
 static PyObject *
-descr_repr(PyDescrObject *descr, char *format)
+descr_repr(PyDescrObject *descr, const char *format)
 {
     PyObject *name = NULL;
     if (descr->d_name != NULL && PyUnicode_Check(descr->d_name))
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1925,7 +1925,7 @@
 }
 
 static int
-dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, char *methname)
+dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, const char *methname)
 {
     PyObject *arg = NULL;
     int result = 0;
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -1133,7 +1133,7 @@
     return -1;
 }
 
-Py_LOCAL_INLINE(char *)
+Py_LOCAL_INLINE(const char *)
 get_native_fmtstr(const char *fmt)
 {
     int at = 0;
@@ -1221,7 +1221,7 @@
         goto out;
     }
 
-    view->format = get_native_fmtstr(PyBytes_AS_STRING(asciifmt));
+    view->format = (char *)get_native_fmtstr(PyBytes_AS_STRING(asciifmt));
     if (view->format == NULL) {
         /* NOT_REACHED: get_native_fmtchar() already validates the format. */
         PyErr_SetString(PyExc_RuntimeError,
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -564,7 +564,7 @@
 static PyTypeObject *best_base(PyObject *);
 static int mro_internal(PyTypeObject *, PyObject **);
 Py_LOCAL_INLINE(int) type_is_subtype_base_chain(PyTypeObject *, PyTypeObject *);
-static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, char *);
+static int compatible_for_assignment(PyTypeObject *, PyTypeObject *, const char *);
 static int add_subclass(PyTypeObject*, PyTypeObject*);
 static int add_all_subclasses(PyTypeObject *type, PyObject *bases);
 static void remove_subclass(PyTypeObject *, PyTypeObject *);
@@ -1435,7 +1435,7 @@
    as lookup_method to cache the interned name string object. */
 
 static PyObject *
-call_method(PyObject *o, _Py_Identifier *nameid, char *format, ...)
+call_method(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
 {
     va_list va;
     PyObject *args, *func = 0, *retval;
@@ -1471,7 +1471,7 @@
 /* Clone of call_method() that returns NotImplemented when the lookup fails. */
 
 static PyObject *
-call_maybe(PyObject *o, _Py_Identifier *nameid, char *format, ...)
+call_maybe(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
 {
     va_list va;
     PyObject *args, *func = 0, *retval;
@@ -3609,7 +3609,7 @@
 }
 
 static int
-compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, char* attr)
+compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, const char* attr)
 {
     PyTypeObject *newbase, *oldbase;
 
@@ -5348,7 +5348,7 @@
 /* Helper to check for object.__setattr__ or __delattr__ applied to a type.
    This is called the Carlo Verre hack after its discoverer. */
 static int
-hackcheck(PyObject *self, setattrofunc func, char *what)
+hackcheck(PyObject *self, setattrofunc func, const char *what)
 {
     PyTypeObject *type = Py_TYPE(self);
     while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -6986,7 +6986,7 @@
 #  define WC_ERR_INVALID_CHARS 0x0080
 #endif
 
-static char*
+static const char*
 code_page_name(UINT code_page, PyObject **obj)
 {
     *obj = NULL;
@@ -7094,7 +7094,7 @@
     PyObject *errorHandler = NULL;
     PyObject *exc = NULL;
     PyObject *encoding_obj = NULL;
-    char *encoding;
+    const char *encoding;
     DWORD err;
     int ret = -1;
 
@@ -7438,7 +7438,7 @@
     PyObject *errorHandler = NULL;
     PyObject *exc = NULL;
     PyObject *encoding_obj = NULL;
-    char *encoding;
+    const char *encoding;
     Py_ssize_t newpos, newoutsize;
     PyObject *rep;
     int ret = -1;
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -265,7 +265,7 @@
 }
 
 static int
-parse_weakref_init_args(char *funcname, PyObject *args, PyObject *kwargs,
+parse_weakref_init_args(const char *funcname, PyObject *args, PyObject *kwargs,
                         PyObject **obp, PyObject **callbackp)
 {
     /* XXX Should check that kwargs == NULL or is empty. */
diff --git a/Parser/pgen.c b/Parser/pgen.c
--- a/Parser/pgen.c
+++ b/Parser/pgen.c
@@ -379,7 +379,7 @@
 
 /* Forward */
 static void printssdfa(int xx_nstates, ss_state *xx_state, int nbits,
-                       labellist *ll, char *msg);
+                       labellist *ll, const char *msg);
 static void simplify(int xx_nstates, ss_state *xx_state);
 static void convert(dfa *d, int xx_nstates, ss_state *xx_state);
 
@@ -494,7 +494,7 @@
 
 static void
 printssdfa(int xx_nstates, ss_state *xx_state, int nbits,
-           labellist *ll, char *msg)
+           labellist *ll, const char *msg)
 {
     int i, ibit, iarc;
     ss_state *yy;
diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c
--- a/Parser/pgenmain.c
+++ b/Parser/pgenmain.c
@@ -27,7 +27,7 @@
 int Py_IgnoreEnvironmentFlag;
 
 /* Forward */
-grammar *getgrammar(char *filename);
+grammar *getgrammar(const char *filename);
 
 void Py_Exit(int) _Py_NO_RETURN;
 
@@ -76,7 +76,7 @@
 }
 
 grammar *
-getgrammar(char *filename)
+getgrammar(const char *filename)
 {
     FILE *fp;
     node *n;
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -202,8 +202,8 @@
 }
 
 
-static char *
-get_normal_name(char *s)        /* for utf-8 and latin-1 */
+static const char *
+get_normal_name(const char *s)  /* for utf-8 and latin-1 */
 {
     char buf[13];
     int i;
@@ -264,7 +264,7 @@
 
             if (begin < t) {
                 char* r = new_string(begin, t - begin, tok);
-                char* q;
+                const char* q;
                 if (!r)
                     return 0;
                 q = get_normal_name(r);
diff --git a/Python/_warnings.c b/Python/_warnings.c
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -921,7 +921,7 @@
 #undef PyErr_Warn
 
 PyAPI_FUNC(int)
-PyErr_Warn(PyObject *category, char *text)
+PyErr_Warn(PyObject *category, const char *text)
 {
     return PyErr_WarnEx(category, text, 1);
 }
diff --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -125,7 +125,7 @@
 
 #ifdef LLTRACE
 static int lltrace;
-static int prtrace(PyObject *, char *);
+static int prtrace(PyObject *, const char *);
 #endif
 static int call_trace(Py_tracefunc, PyObject *,
                       PyThreadState *, PyFrameObject *,
@@ -4308,7 +4308,7 @@
 
 #ifdef LLTRACE
 static int
-prtrace(PyObject *v, char *str)
+prtrace(PyObject *v, const char *str)
 {
     printf("%s ", str);
     if (PyObject_Print(v, stdout, 0) != 0)
diff --git a/Python/dtoa.c b/Python/dtoa.c
--- a/Python/dtoa.c
+++ b/Python/dtoa.c
@@ -2315,7 +2315,7 @@
 }
 
 static char *
-nrv_alloc(char *s, char **rve, int n)
+nrv_alloc(const char *s, char **rve, int n)
 {
     char *rv, *t;
 
diff --git a/Python/dynload_win.c b/Python/dynload_win.c
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -41,7 +41,7 @@
 /* Case insensitive string compare, to avoid any dependencies on particular
    C RTL implementations */
 
-static int strcasecmp (char *string1, char *string2)
+static int strcasecmp (const char *string1, const char *string2)
 {
     int first, second;
 
diff --git a/Python/getargs.c b/Python/getargs.c
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -20,12 +20,12 @@
 
 #ifdef HAVE_DECLSPEC_DLL
 /* Export functions */
-PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, char *, ...);
-PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, char *, ...);
+PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, const char *, ...);
+PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, const char *, ...);
 PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
                                                   const char *, char **, ...);
 PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
-PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, char *, va_list);
+PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, const char *, va_list);
 PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *,
                                               const char *, char **, va_list);
 #endif
@@ -56,18 +56,18 @@
 /* Forward */
 static int vgetargs1(PyObject *, const char *, va_list *, int);
 static void seterror(Py_ssize_t, const char *, int *, const char *, const char *);
-static char *convertitem(PyObject *, const char **, va_list *, int, int *,
-                         char *, size_t, freelist_t *);
-static char *converttuple(PyObject *, const char **, va_list *, int,
-                          int *, char *, size_t, int, freelist_t *);
-static char *convertsimple(PyObject *, const char **, va_list *, int, char *,
-                           size_t, freelist_t *);
-static Py_ssize_t convertbuffer(PyObject *, void **p, char **);
-static int getbuffer(PyObject *, Py_buffer *, char**);
+static const char *convertitem(PyObject *, const char **, va_list *, int, int *,
+                               char *, size_t, freelist_t *);
+static const char *converttuple(PyObject *, const char **, va_list *, int,
+                                int *, char *, size_t, int, freelist_t *);
+static const char *convertsimple(PyObject *, const char **, va_list *, int,
+                                 char *, size_t, freelist_t *);
+static Py_ssize_t convertbuffer(PyObject *, void **p, const char **);
+static int getbuffer(PyObject *, Py_buffer *, const char**);
 
 static int vgetargskeywords(PyObject *, PyObject *,
                             const char *, char **, va_list *, int);
-static char *skipitem(const char **, va_list *, int);
+static const char *skipitem(const char **, va_list *, int);
 
 int
 PyArg_Parse(PyObject *args, const char *format, ...)
@@ -82,7 +82,7 @@
 }
 
 int
-_PyArg_Parse_SizeT(PyObject *args, char *format, ...)
+_PyArg_Parse_SizeT(PyObject *args, const char *format, ...)
 {
     int retval;
     va_list va;
@@ -107,7 +107,7 @@
 }
 
 int
-_PyArg_ParseTuple_SizeT(PyObject *args, char *format, ...)
+_PyArg_ParseTuple_SizeT(PyObject *args, const char *format, ...)
 {
     int retval;
     va_list va;
@@ -130,7 +130,7 @@
 }
 
 int
-_PyArg_VaParse_SizeT(PyObject *args, char *format, va_list va)
+_PyArg_VaParse_SizeT(PyObject *args, const char *format, va_list va)
 {
     va_list lva;
 
@@ -208,7 +208,7 @@
     int endfmt = 0;
     const char *formatsave = format;
     Py_ssize_t i, len;
-    char *msg;
+    const char *msg;
     int compat = flags & FLAG_COMPAT;
     freelistentry_t static_entries[STATIC_FREELIST_ENTRIES];
     freelist_t freelist;
@@ -416,7 +416,7 @@
       and msgbuf is returned.
 */
 
-static char *
+static const char *
 converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
              int *levels, char *msgbuf, size_t bufsize, int toplevel,
              freelist_t *freelist)
@@ -474,7 +474,7 @@
 
     format = *p_format;
     for (i = 0; i < n; i++) {
-        char *msg;
+        const char *msg;
         PyObject *item;
         item = PySequence_GetItem(arg, i);
         if (item == NULL) {
@@ -501,11 +501,11 @@
 
 /* Convert a single item. */
 
-static char *
+static const char *
 convertitem(PyObject *arg, const char **p_format, va_list *p_va, int flags,
             int *levels, char *msgbuf, size_t bufsize, freelist_t *freelist)
 {
-    char *msg;
+    const char *msg;
     const char *format = *p_format;
 
     if (*format == '(' /* ')' */) {
@@ -530,7 +530,7 @@
 
 /* Format an error message generated by convertsimple(). */
 
-static char *
+static const char *
 converterr(const char *expected, PyObject *arg, char *msgbuf, size_t bufsize)
 {
     assert(expected != NULL);
@@ -566,7 +566,7 @@
    When you add new format codes, please don't forget poor skipitem() below.
 */
 
-static char *
+static const char *
 convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
               char *msgbuf, size_t bufsize, freelist_t *freelist)
 {
@@ -851,7 +851,7 @@
 
     case 'y': {/* any bytes-like object */
         void **p = (void **)va_arg(*p_va, char **);
-        char *buf;
+        const char *buf;
         Py_ssize_t count;
         if (*format == '*') {
             if (getbuffer(arg, (Py_buffer*)p, &buf) < 0)
@@ -898,7 +898,7 @@
                 PyBuffer_FillInfo(p, arg, sarg, len, 1, 0);
             }
             else { /* any bytes-like object */
-                char *buf;
+                const char *buf;
                 if (getbuffer(arg, p, &buf) < 0)
                     return converterr(buf, arg, msgbuf, bufsize);
             }
@@ -928,7 +928,7 @@
             }
             else { /* read-only bytes-like object */
                 /* XXX Really? */
-                char *buf;
+                const char *buf;
                 Py_ssize_t count = convertbuffer(arg, p, &buf);
                 if (count < 0)
                     return converterr(buf, arg, msgbuf, bufsize);
@@ -1275,7 +1275,7 @@
 }
 
 static Py_ssize_t
-convertbuffer(PyObject *arg, void **p, char **errmsg)
+convertbuffer(PyObject *arg, void **p, const char **errmsg)
 {
     PyBufferProcs *pb = Py_TYPE(arg)->tp_as_buffer;
     Py_ssize_t count;
@@ -1297,7 +1297,7 @@
 }
 
 static int
-getbuffer(PyObject *arg, Py_buffer *view, char **errmsg)
+getbuffer(PyObject *arg, Py_buffer *view, const char **errmsg)
 {
     if (PyObject_GetBuffer(arg, view, PyBUF_SIMPLE) != 0) {
         *errmsg = "bytes-like object";
@@ -1629,7 +1629,7 @@
 }
 
 
-static char *
+static const char *
 skipitem(const char **p_format, va_list *p_va, int flags)
 {
     const char *format = *p_format;
@@ -1722,7 +1722,7 @@
 
     case '(':           /* bypass tuple, not handled at all previously */
         {
-            char *msg;
+            const char *msg;
             for (;;) {
                 if (*format==')')
                     break;
diff --git a/Python/marshal.c b/Python/marshal.c
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -643,7 +643,7 @@
     PyObject *refs;  /* a list */
 } RFILE;
 
-static char *
+static const char *
 r_string(Py_ssize_t n, RFILE *p)
 {
     Py_ssize_t read = -1;
@@ -729,7 +729,7 @@
         c = getc(p->fp);
     }
     else {
-        char *ptr = r_string(1, p);
+        const char *ptr = r_string(1, p);
         if (ptr != NULL)
             c = *(unsigned char *) ptr;
     }
@@ -740,9 +740,9 @@
 r_short(RFILE *p)
 {
     short x = -1;
-    unsigned char *buffer;
+    const unsigned char *buffer;
 
-    buffer = (unsigned char *) r_string(2, p);
+    buffer = (const unsigned char *) r_string(2, p);
     if (buffer != NULL) {
         x = buffer[0];
         x |= buffer[1] << 8;
@@ -756,9 +756,9 @@
 r_long(RFILE *p)
 {
     long x = -1;
-    unsigned char *buffer;
+    const unsigned char *buffer;
 
-    buffer = (unsigned char *) r_string(4, p);
+    buffer = (const unsigned char *) r_string(4, p);
     if (buffer != NULL) {
         x = buffer[0];
         x |= (long)buffer[1] << 8;
@@ -978,7 +978,8 @@
 
     case TYPE_FLOAT:
         {
-            char buf[256], *ptr;
+            char buf[256];
+            const char *ptr;
             double dx;
             n = r_byte(p);
             if (n == EOF) {
@@ -1001,9 +1002,9 @@
 
     case TYPE_BINARY_FLOAT:
         {
-            unsigned char *buf;
+            const unsigned char *buf;
             double x;
-            buf = (unsigned char *) r_string(8, p);
+            buf = (const unsigned char *) r_string(8, p);
             if (buf == NULL)
                 break;
             x = _PyFloat_Unpack8(buf, 1);
@@ -1016,7 +1017,8 @@
 
     case TYPE_COMPLEX:
         {
-            char buf[256], *ptr;
+            char buf[256];
+            const char *ptr;
             Py_complex c;
             n = r_byte(p);
             if (n == EOF) {
@@ -1053,15 +1055,15 @@
 
     case TYPE_BINARY_COMPLEX:
         {
-            unsigned char *buf;
+            const unsigned char *buf;
             Py_complex c;
-            buf = (unsigned char *) r_string(8, p);
+            buf = (const unsigned char *) r_string(8, p);
             if (buf == NULL)
                 break;
             c.real = _PyFloat_Unpack8(buf, 1);
             if (c.real == -1.0 && PyErr_Occurred())
                 break;
-            buf = (unsigned char *) r_string(8, p);
+            buf = (const unsigned char *) r_string(8, p);
             if (buf == NULL)
                 break;
             c.imag = _PyFloat_Unpack8(buf, 1);
@@ -1074,7 +1076,7 @@
 
     case TYPE_STRING:
         {
-            char *ptr;
+            const char *ptr;
             n = r_long(p);
             if (PyErr_Occurred())
                 break;
@@ -1119,7 +1121,7 @@
         }
     _read_ascii:
         {
-            char *ptr;
+            const char *ptr;
             ptr = r_string(n, p);
             if (ptr == NULL)
                 break;
@@ -1137,7 +1139,7 @@
         is_interned = 1;
     case TYPE_UNICODE:
         {
-        char *buffer;
+        const char *buffer;
 
         n = r_long(p);
         if (PyErr_Occurred())
diff --git a/Python/modsupport.c b/Python/modsupport.c
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -301,7 +301,7 @@
         case 'U':   /* XXX deprecated alias */
         {
             PyObject *v;
-            char *str = va_arg(*p_va, char *);
+            const char *str = va_arg(*p_va, const char *);
             Py_ssize_t n;
             if (**p_format == '#') {
                 ++*p_format;
@@ -334,7 +334,7 @@
         case 'y':
         {
             PyObject *v;
-            char *str = va_arg(*p_va, char *);
+            const char *str = va_arg(*p_va, const char *);
             Py_ssize_t n;
             if (**p_format == '#') {
                 ++*p_format;
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1004,8 +1004,8 @@
 /* returns Py_None if the fd is not valid */
 static PyObject*
 create_stdio(PyObject* io,
-    int fd, int write_mode, char* name,
-    char* encoding, char* errors)
+    int fd, int write_mode, const char* name,
+    const char* encoding, const char* errors)
 {
     PyObject *buf = NULL, *stream = NULL, *text = NULL, *raw = NULL, *res;
     const char* mode;
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1138,8 +1138,8 @@
 
 mod_ty
 PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc,
-                           int start, char *ps1,
-                           char *ps2, PyCompilerFlags *flags, int *errcode,
+                           int start, const char *ps1,
+                           const char *ps2, PyCompilerFlags *flags, int *errcode,
                            PyArena *arena)
 {
     mod_ty mod;
@@ -1171,8 +1171,8 @@
 
 mod_ty
 PyParser_ASTFromFile(FILE *fp, const char *filename_str, const char* enc,
-                     int start, char *ps1,
-                     char *ps2, PyCompilerFlags *flags, int *errcode,
+                     int start, const char *ps1,
+                     const char *ps2, PyCompilerFlags *flags, int *errcode,
                      PyArena *arena)
 {
     mod_ty mod;
diff --git a/Python/symtable.c b/Python/symtable.c
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -160,7 +160,7 @@
 };
 
 static int symtable_analyze(struct symtable *st);
-static int symtable_warn(struct symtable *st, char *msg, int lineno);
+static int symtable_warn(struct symtable *st, const char *msg, int lineno);
 static int symtable_enter_block(struct symtable *st, identifier name,
                                 _Py_block_ty block, void *ast, int lineno,
                                 int col_offset);
@@ -903,7 +903,7 @@
 
 
 static int
-symtable_warn(struct symtable *st, char *msg, int lineno)
+symtable_warn(struct symtable *st, const char *msg, int lineno)
 {
     PyObject *message = PyUnicode_FromString(msg);
     if (message == NULL)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list