]> granicus.if.org Git - python/commitdiff
Issue #25923: Added the const qualifier to static constant arrays.
authorSerhiy Storchaka <storchaka@gmail.com>
Fri, 25 Dec 2015 17:53:18 +0000 (19:53 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Fri, 25 Dec 2015 17:53:18 +0000 (19:53 +0200)
44 files changed:
Include/py_curses.h
Include/pymath.h
Modules/_csv.c
Modules/_ctypes/_ctypes.c
Modules/_ctypes/callproc.c
Modules/_curses_panel.c
Modules/_datetimemodule.c
Modules/_dbmmodule.c
Modules/_gdbmmodule.c
Modules/_io/textio.c
Modules/_randommodule.c
Modules/_sqlite/connection.c
Modules/_sqlite/cursor.c
Modules/_sqlite/module.c
Modules/_sre.c
Modules/_struct.c
Modules/_testbuffer.c
Modules/_testcapimodule.c
Modules/arraymodule.c
Modules/audioop.c
Modules/binascii.c
Modules/getaddrinfo.c
Modules/getpath.c
Modules/main.c
Modules/parsermodule.c
Modules/posixmodule.c
Modules/selectmodule.c
Modules/timemodule.c
Modules/unicodedata.c
Objects/object.c
Objects/structseq.c
Objects/typeobject.c
Objects/unicodeobject.c
Parser/parsetok.c
Parser/pgen.c
Python/ast.c
Python/dtoa.c
Python/formatter_unicode.c
Python/import.c
Python/importdl.c
Python/mystrtoul.c
Python/pystrtod.c
Python/pythonrun.c
Python/sysmodule.c

index f2c08f6413a8635d85728d40301c40dccc83c0cc..3c21697073a4a6be6efb3c0e0e57fdc0dfd11f86 100644 (file)
@@ -103,8 +103,8 @@ static void **PyCurses_API;
 #endif
 
 /* general error messages */
-static char *catchall_ERR  = "curses function returned ERR";
-static char *catchall_NULL = "curses function returned NULL";
+static const char catchall_ERR[]  = "curses function returned ERR";
+static const char catchall_NULL[] = "curses function returned NULL";
 
 /* Function Prototype Macros - They are ugly but very, very useful. ;-)
 
index 1ea9ac1437a013196229eaa02acba9b7d069bd6a..ed76053b816229f590e5fdb52b5dc43b0cce7e92 100644 (file)
@@ -169,7 +169,7 @@ PyAPI_FUNC(void) _Py_set_387controlword(unsigned short);
         #pragma float_control (pop)
         #define Py_NAN __icc_nan()
     #else /* ICC_NAN_RELAXED as default for Intel Compiler */
-        static union { unsigned char buf[8]; double __icc_nan; } __nan_store = {0,0,0,0,0,0,0xf8,0x7f};
+        static const union { unsigned char buf[8]; double __icc_nan; } __nan_store = {0,0,0,0,0,0,0xf8,0x7f};
         #define Py_NAN (__nan_store.__icc_nan)
     #endif /* ICC_NAN_STRICT */
 #endif /* __INTEL_COMPILER */
index fe85069435083236ade5faf961325c226de6033e..c0be739c672970e45b4b57fd0ce185c8d4498d23 100644 (file)
@@ -60,10 +60,10 @@ typedef enum {
 
 typedef struct {
     QuoteStyle style;
-    char *name;
+    const char *name;
 } StyleDesc;
 
-static StyleDesc quote_styles[] = {
+static const StyleDesc quote_styles[] = {
     { QUOTE_MINIMAL,    "QUOTE_MINIMAL" },
     { QUOTE_ALL,        "QUOTE_ALL" },
     { QUOTE_NONNUMERIC, "QUOTE_NONNUMERIC" },
@@ -286,7 +286,7 @@ _set_str(const char *name, PyObject **target, PyObject *src, const char *dflt)
 static int
 dialect_check_quoting(int quoting)
 {
-    StyleDesc *qs;
+    const StyleDesc *qs;
 
     for (qs = quote_styles; qs->name; qs++) {
         if ((int)qs->style == quoting)
@@ -1633,7 +1633,7 @@ PyMODINIT_FUNC
 PyInit__csv(void)
 {
     PyObject *module;
-    StyleDesc *style;
+    const StyleDesc *style;
 
     if (PyType_Ready(&Dialect_Type) < 0)
         return NULL;
index 34a10994be63cf8776afce32056daaeda9bad5a7..fccc8ba99334c8fecf7eec31b3371c95cda65e28 100644 (file)
@@ -435,7 +435,7 @@ UnionType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
     return StructUnionType_new(type, args, kwds, 0);
 }
 
-static char from_address_doc[] =
+static const char from_address_doc[] =
 "C.from_address(integer) -> C instance\naccess a C instance at the specified address";
 
 static PyObject *
@@ -453,7 +453,7 @@ CDataType_from_address(PyObject *type, PyObject *value)
     return PyCData_AtAddress(type, buf);
 }
 
-static char from_buffer_doc[] =
+static const char from_buffer_doc[] =
 "C.from_buffer(object, offset=0) -> C instance\ncreate a C instance from a writeable buffer";
 
 static int
@@ -524,7 +524,7 @@ CDataType_from_buffer(PyObject *type, PyObject *args)
     return result;
 }
 
-static char from_buffer_copy_doc[] =
+static const char from_buffer_copy_doc[] =
 "C.from_buffer_copy(object, offset=0) -> C instance\ncreate a C instance from a readable buffer";
 
 static PyObject *
@@ -566,7 +566,7 @@ CDataType_from_buffer_copy(PyObject *type, PyObject *args)
     return result;
 }
 
-static char in_dll_doc[] =
+static const char in_dll_doc[] =
 "C.in_dll(dll, name) -> C instance\naccess a C instance in a dll";
 
 static PyObject *
@@ -623,7 +623,7 @@ CDataType_in_dll(PyObject *type, PyObject *args)
     return PyCData_AtAddress(type, address);
 }
 
-static char from_param_doc[] =
+static const char from_param_doc[] =
 "Convert a Python object into a function call parameter.";
 
 static PyObject *
@@ -1481,7 +1481,7 @@ _type_ attribute.
 
 */
 
-static char *SIMPLE_TYPE_CHARS = "cbBhHiIlLdfuzZqQPXOv?g";
+static const char SIMPLE_TYPE_CHARS[] = "cbBhHiIlLdfuzZqQPXOv?g";
 
 static PyObject *
 c_wchar_p_from_param(PyObject *type, PyObject *value)
@@ -5118,7 +5118,7 @@ static const char module_docs[] =
 
 #ifdef MS_WIN32
 
-static char comerror_doc[] = "Raised when a COM method call failed.";
+static const char comerror_doc[] = "Raised when a COM method call failed.";
 
 int
 comerror_init(PyObject *self, PyObject *args, PyObject *kwds)
index 03a911fa0698f82d8c04bbfdc02f252ac13563bf..68981fe84a0d882fbff6b2d723f173a536a29b3b 100644 (file)
@@ -1201,7 +1201,7 @@ _parse_voidp(PyObject *obj, void **address)
 
 #ifdef MS_WIN32
 
-static char format_error_doc[] =
+static const char format_error_doc[] =
 "FormatError([integer]) -> string\n\
 \n\
 Convert a win32 error code into a string. If the error code is not\n\
@@ -1225,7 +1225,7 @@ static PyObject *format_error(PyObject *self, PyObject *args)
     return result;
 }
 
-static char load_library_doc[] =
+static const char load_library_doc[] =
 "LoadLibrary(name) -> handle\n\
 \n\
 Load an executable (usually a DLL), and return a handle to it.\n\
@@ -1254,7 +1254,7 @@ static PyObject *load_library(PyObject *self, PyObject *args)
 #endif
 }
 
-static char free_library_doc[] =
+static const char free_library_doc[] =
 "FreeLibrary(handle) -> void\n\
 \n\
 Free the handle of an executable previously loaded by LoadLibrary.\n";
@@ -1269,7 +1269,7 @@ static PyObject *free_library(PyObject *self, PyObject *args)
     return Py_None;
 }
 
-static char copy_com_pointer_doc[] =
+static const char copy_com_pointer_doc[] =
 "CopyComPointer(src, dst) -> HRESULT value\n";
 
 static PyObject *
@@ -1439,7 +1439,7 @@ call_cdeclfunction(PyObject *self, PyObject *args)
 /*****************************************************************
  * functions
  */
-static char sizeof_doc[] =
+static const char sizeof_doc[] =
 "sizeof(C type) -> integer\n"
 "sizeof(C instance) -> integer\n"
 "Return the size in bytes of a C instance";
@@ -1460,7 +1460,7 @@ sizeof_func(PyObject *self, PyObject *obj)
     return NULL;
 }
 
-static char alignment_doc[] =
+static const char alignment_doc[] =
 "alignment(C type) -> integer\n"
 "alignment(C instance) -> integer\n"
 "Return the alignment requirements of a C instance";
@@ -1483,7 +1483,7 @@ align_func(PyObject *self, PyObject *obj)
     return NULL;
 }
 
-static char byref_doc[] =
+static const char byref_doc[] =
 "byref(C instance[, offset=0]) -> byref-object\n"
 "Return a pointer lookalike to a C instance, only usable\n"
 "as function argument";
@@ -1527,7 +1527,7 @@ byref(PyObject *self, PyObject *args)
     return (PyObject *)parg;
 }
 
-static char addressof_doc[] =
+static const char addressof_doc[] =
 "addressof(C instance) -> integer\n"
 "Return the address of the C instance internal buffer";
 
index 759b73109d25c16028678dc985117e6848bae23e..a9c406fde96a4f9c6bcd3bf4866bd970990bb459 100644 (file)
@@ -6,7 +6,7 @@
 
 /* Release Number */
 
-static char *PyCursesVersion = "2.1";
+static const char PyCursesVersion[] = "2.1";
 
 /* Includes */
 
index 55988c56930ab20e5926079f31539c7b4136b95e..e8b7ae8e4f5b024041acf5c77561fd711ac7fa50 100644 (file)
@@ -184,12 +184,12 @@ divide_nearest(PyObject *m, PyObject *n)
  * and the number of days before that month in the same year.  These
  * are correct for non-leap years only.
  */
-static int _days_in_month[] = {
+static const int _days_in_month[] = {
     0, /* unused; this vector uses 1-based indexing */
     31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
 };
 
-static int _days_before_month[] = {
+static const int _days_before_month[] = {
     0, /* unused; this vector uses 1-based indexing */
     0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
 };
@@ -1009,10 +1009,10 @@ append_keyword_tzinfo(PyObject *repr, PyObject *tzinfo)
 static PyObject *
 format_ctime(PyDateTime_Date *date, int hours, int minutes, int seconds)
 {
-    static const char *DayNames[] = {
+    static const char * const DayNames[] = {
         "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
     };
-    static const char *MonthNames[] = {
+    static const char * const MonthNames[] = {
         "Jan", "Feb", "Mar", "Apr", "May", "Jun",
         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
     };
@@ -2307,7 +2307,7 @@ static PyMethodDef delta_methods[] = {
     {NULL,      NULL},
 };
 
-static char delta_doc[] =
+static const char delta_doc[] =
 PyDoc_STR("Difference between two datetime values.");
 
 static PyNumberMethods delta_as_number = {
@@ -2886,7 +2886,7 @@ static PyMethodDef date_methods[] = {
     {NULL,      NULL}
 };
 
-static char date_doc[] =
+static const char date_doc[] =
 PyDoc_STR("date(year, month, day) --> date object");
 
 static PyNumberMethods date_as_number = {
@@ -3155,7 +3155,7 @@ static PyMethodDef tzinfo_methods[] = {
     {NULL, NULL}
 };
 
-static char tzinfo_doc[] =
+static const char tzinfo_doc[] =
 PyDoc_STR("Abstract base class for time zone info objects.");
 
 static PyTypeObject PyDateTime_TZInfoType = {
@@ -3387,7 +3387,7 @@ static PyMethodDef timezone_methods[] = {
     {NULL, NULL}
 };
 
-static char timezone_doc[] =
+static const char timezone_doc[] =
 PyDoc_STR("Fixed offset from UTC implementation of tzinfo.");
 
 static PyTypeObject PyDateTime_TimeZoneType = {
@@ -3877,7 +3877,7 @@ static PyMethodDef time_methods[] = {
     {NULL,      NULL}
 };
 
-static char time_doc[] =
+static const char time_doc[] =
 PyDoc_STR("time([hour[, minute[, second[, microsecond[, tzinfo]]]]]) --> a time object\n\
 \n\
 All arguments are optional. tzinfo may be None, or an instance of\n\
@@ -5065,7 +5065,7 @@ static PyMethodDef datetime_methods[] = {
     {NULL,      NULL}
 };
 
-static char datetime_doc[] =
+static const char datetime_doc[] =
 PyDoc_STR("datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])\n\
 \n\
 The year, month and day arguments are required. tzinfo may be None, or an\n\
index 02899e4303e0705e1a5ed2e8b5c9821d0ba58feb..5e7ec1afc8281e65afd48925d60b9a6f2d826a27 100644 (file)
  */
 #if defined(HAVE_NDBM_H)
 #include <ndbm.h>
-static char *which_dbm = "GNU gdbm";  /* EMX port of GDBM */
+static const char which_dbm[] = "GNU gdbm";  /* EMX port of GDBM */
 #elif defined(HAVE_GDBM_NDBM_H)
 #include <gdbm/ndbm.h>
-static char *which_dbm = "GNU gdbm";
+static const char which_dbm[] = "GNU gdbm";
 #elif defined(HAVE_GDBM_DASH_NDBM_H)
 #include <gdbm-ndbm.h>
-static char *which_dbm = "GNU gdbm";
+static const char which_dbm[] = "GNU gdbm";
 #elif defined(HAVE_BERKDB_H)
 #include <db.h>
-static char *which_dbm = "Berkeley DB";
+static const char which_dbm[] = "Berkeley DB";
 #else
 #error "No ndbm.h available!"
 #endif
index f070a140079a133162f7139d3ebaadad90d9d5ea..bf7b03694fa8a5eeb05ba9813d3284120c5af055 100644 (file)
@@ -615,7 +615,7 @@ dbmopen_impl(PyModuleDef *module, const char *name, const char *flags,
     return newdbmobject(name, iflags, mode);
 }
 
-static char dbmmodule_open_flags[] = "rwcn"
+static const char dbmmodule_open_flags[] = "rwcn"
 #ifdef GDBM_FAST
                                      "f"
 #endif
index b232b0242e515c27159298fe66eabe53235847c9..d018623470705d5bafa507dbc7d5eb4b0abbbb24 100644 (file)
@@ -772,7 +772,7 @@ typedef struct {
     encodefunc_t encodefunc;
 } encodefuncentry;
 
-static encodefuncentry encodefuncs[] = {
+static const encodefuncentry encodefuncs[] = {
     {"ascii",       (encodefunc_t) ascii_encode},
     {"iso8859-1",   (encodefunc_t) latin1_encode},
     {"utf-8",       (encodefunc_t) utf8_encode},
@@ -1022,7 +1022,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
                 goto error;
         }
         else if (PyUnicode_Check(res)) {
-            encodefuncentry *e = encodefuncs;
+            const encodefuncentry *e = encodefuncs;
             while (e->name != NULL) {
                 if (!PyUnicode_CompareWithASCIIString(res, e->name)) {
                     self->encodefunc = e->encodefunc;
index 95ad4a429a04f06a0c1784abf107dc33f70059d9..a85d905c5241af8c95dba18976a95b44eeef4eb0 100644 (file)
@@ -99,7 +99,7 @@ static PY_UINT32_T
 genrand_int32(RandomObject *self)
 {
     PY_UINT32_T y;
-    static PY_UINT32_T mag01[2]={0x0U, MATRIX_A};
+    static const PY_UINT32_T mag01[2] = {0x0U, MATRIX_A};
     /* mag01[x] = x * MATRIX_A  for x=0,1 */
     PY_UINT32_T *mt;
 
index 7018f9f3dc14e7b13236f30eaf1b268beb01bb98..75ed1f8c88a2bbabf4c65e2f270d34a5253b56a1 100644 (file)
@@ -1622,7 +1622,7 @@ pysqlite_connection_exit(pysqlite_Connection* self, PyObject* args)
     Py_RETURN_FALSE;
 }
 
-static char connection_doc[] =
+static const char connection_doc[] =
 PyDoc_STR("SQLite database connection object.");
 
 static PyGetSetDef connection_getset[] = {
index d909738fd6af34f5cb47ab63276b71510a08502c..1c240d61450d4d8bee73a951fe46620709854a06 100644 (file)
@@ -27,7 +27,7 @@
 
 PyObject* pysqlite_cursor_iternext(pysqlite_Cursor* self);
 
-static char* errmsg_fetch_across_rollback = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from.";
+static const char errmsg_fetch_across_rollback[] = "Cursor needed to be reset because of commit/rollback and can no longer be fetched from.";
 
 static pysqlite_StatementKind detect_statement_type(const char* statement)
 {
@@ -1050,7 +1050,7 @@ static struct PyMemberDef cursor_members[] =
     {NULL}
 };
 
-static char cursor_doc[] =
+static const char cursor_doc[] =
 PyDoc_STR("SQLite database cursor class.");
 
 PyTypeObject pysqlite_CursorType = {
index 7a7e86040abe10854430a2616bd1750ab7355e0a..ff2e3a5dff8b91c8f0d9df91fcef5695e9ac8a7a 100644 (file)
@@ -261,13 +261,13 @@ static PyMethodDef module_methods[] = {
 };
 
 struct _IntConstantPair {
-    char* constant_name;
+    const char *constant_name;
     int constant_value;
 };
 
 typedef struct _IntConstantPair IntConstantPair;
 
-static IntConstantPair _int_constants[] = {
+static const IntConstantPair _int_constants[] = {
     {"PARSE_DECLTYPES", PARSE_DECLTYPES},
     {"PARSE_COLNAMES", PARSE_COLNAMES},
 
index 919a0693efd22b8606a7a88cdbaaf995ea7b9f69..f597a7032fe7d1fa69f564cfafba136b11ae15a5 100644 (file)
@@ -35,7 +35,7 @@
  * other compatibility work.
  */
 
-static char copyright[] =
+static const char copyright[] =
     " SRE 2.2.2 Copyright (c) 1997-2002 by Secret Labs AB ";
 
 #define PY_SSIZE_T_CLEAN
index b61f9f6fa9cafad942a2b3508744f968a75dc83e..b18c71da60cb4a70fb782f235369ecfe4c277e29 100644 (file)
@@ -723,7 +723,7 @@ np_void_p(char *p, PyObject *v, const formatdef *f)
     return 0;
 }
 
-static formatdef native_table[] = {
+static const formatdef native_table[] = {
     {'x',       sizeof(char),   0,              NULL},
     {'b',       sizeof(char),   0,              nu_byte,        np_byte},
     {'B',       sizeof(char),   0,              nu_ubyte,       np_ubyte},
@@ -2280,7 +2280,7 @@ PyInit__struct(void)
 
     /* Check endian and swap in faster functions */
     {
-        formatdef *native = native_table;
+        const formatdef *native = native_table;
         formatdef *other, *ptr;
 #if PY_LITTLE_ENDIAN
         other = lilendian_table;
index 43db8a8e53a34a3826c5517109f081d406b313fc..13d3cccfa4ff7fd91ae70d588f9288f9a402e9e2 100644 (file)
@@ -13,7 +13,7 @@ PyObject *Struct = NULL;
 PyObject *calcsize = NULL;
 
 /* cache simple format string */
-static const char *simple_fmt = "B";
+static const char simple_fmt[] = "B";
 PyObject *simple_format = NULL;
 #define SIMPLE_FORMAT(fmt) (fmt == NULL || strcmp(fmt, "B") == 0)
 #define FIX_FORMAT(fmt) (fmt == NULL ? "B" : fmt)
index a896af0cc0ed503ab5e7ebf02012323261fc7d2e..cc3f52d1e02755f9a3feda264de509a02a63c201 100644 (file)
@@ -887,7 +887,7 @@ static PyObject *
 getargs_keywords(PyObject *self, PyObject *args, PyObject *kwargs)
 {
     static char *keywords[] = {"arg1","arg2","arg3","arg4","arg5", NULL};
-    static char *fmt="(ii)i|(i(ii))(iii)i";
+    static const char fmt[] = "(ii)i|(i(ii))(iii)i";
     int int_args[10]={-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs, fmt, keywords,
@@ -3769,7 +3769,7 @@ test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
         "T_LONGLONG", "T_ULONGLONG",
 #endif
         NULL};
-    static char *fmt = "|bbBhHiIlknfds#"
+    static const char fmt[] = "|bbBhHiIlknfds#"
 #ifdef HAVE_LONG_LONG
         "LK"
 #endif
index 6af75a4357a356fa1d7fc44930d9998d45dba7c9..1b0a2823a1f08d08cda0a762597226ff87b5590e 100644 (file)
@@ -31,7 +31,7 @@ struct arraydescr {
     int itemsize;
     PyObject * (*getitem)(struct arrayobject *, Py_ssize_t);
     int (*setitem)(struct arrayobject *, Py_ssize_t, PyObject *);
-    char *formats;
+    const char *formats;
     int is_integer_type;
     int is_signed;
 };
@@ -40,7 +40,7 @@ typedef struct arrayobject {
     PyObject_VAR_HEAD
     char *ob_item;
     Py_ssize_t allocated;
-    struct arraydescr *ob_descr;
+    const struct arraydescr *ob_descr;
     PyObject *weakreflist; /* List of weak references */
     int ob_exports;  /* Number of exported buffers */
 } arrayobject;
@@ -511,7 +511,7 @@ d_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
  * Don't forget to update typecode_to_mformat_code() if you add a new
  * typecode.
  */
-static struct arraydescr descriptors[] = {
+static const struct arraydescr descriptors[] = {
     {'b', 1, b_getitem, b_setitem, "b", 1, 1},
     {'B', 1, BB_getitem, BB_setitem, "B", 1, 0},
     {'u', sizeof(Py_UNICODE), u_getitem, u_setitem, "u", 0, 0},
@@ -539,7 +539,7 @@ class array.array "arrayobject *" "&Arraytype"
 /*[clinic end generated code: output=da39a3ee5e6b4b0d input=ad43d37e942a8854]*/
 
 static PyObject *
-newarrayobject(PyTypeObject *type, Py_ssize_t size, struct arraydescr *descr)
+newarrayobject(PyTypeObject *type, Py_ssize_t size, const struct arraydescr *descr)
 {
     arrayobject *op;
     size_t nbytes;
@@ -1946,7 +1946,7 @@ array__array_reconstructor_impl(PyModuleDef *module, PyTypeObject *arraytype,
 {
     PyObject *converted_items;
     PyObject *result;
-    struct arraydescr *descr;
+    const struct arraydescr *descr;
 
     if (!PyType_Check(arraytype)) {
         PyErr_Format(PyExc_TypeError,
@@ -2084,7 +2084,7 @@ array__array_reconstructor_impl(PyModuleDef *module, PyTypeObject *arraytype,
         Py_ssize_t itemcount = Py_SIZE(items) / mf_descr.size;
         const unsigned char *memstr =
             (unsigned char *)PyBytes_AS_STRING(items);
-        struct arraydescr *descr;
+        const struct arraydescr *descr;
 
         /* If possible, try to pack array's items using a data type
          * that fits better. This may result in an array with narrower
@@ -2554,7 +2554,7 @@ array_buffer_getbuf(arrayobject *self, Py_buffer *view, int flags)
     view->format = NULL;
     view->internal = NULL;
     if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) {
-        view->format = self->ob_descr->formats;
+        view->format = (char *)self->ob_descr->formats;
 #ifdef Py_UNICODE_WIDE
         if (self->ob_descr->typecode == 'u') {
             view->format = "w";
@@ -2595,7 +2595,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
     int c;
     PyObject *initial = NULL, *it = NULL;
-    struct arraydescr *descr;
+    const struct arraydescr *descr;
 
     if (type == &Arraytype && !_PyArg_NoKeywords("array.array()", kwds))
         return NULL;
@@ -2987,7 +2987,7 @@ array_modexec(PyObject *m)
     char buffer[Py_ARRAY_LENGTH(descriptors)], *p;
     PyObject *typecodes;
     Py_ssize_t size = 0;
-    struct arraydescr *descr;
+    const struct arraydescr *descr;
 
     if (PyType_Ready(&Arraytype) < 0)
         return -1;
index 3b05aec06a7ab6ce4b61e8b139d00430180cfacf..d97a3697b2041388a579e0cbb2f9c35ec3b361b2 100644 (file)
@@ -51,13 +51,15 @@ fbound(double val, double minval, double maxval)
 #define SEG_SHIFT       (4)             /* Left shift for segment number. */
 #define SEG_MASK        (0x70)          /* Segment field mask. */
 
-static PyInt16 seg_aend[8] = {0x1F, 0x3F, 0x7F, 0xFF,
-                              0x1FF, 0x3FF, 0x7FF, 0xFFF};
-static PyInt16 seg_uend[8] = {0x3F, 0x7F, 0xFF, 0x1FF,
-                              0x3FF, 0x7FF, 0xFFF, 0x1FFF};
+static const PyInt16 seg_aend[8] = {
+    0x1F, 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF
+};
+static const PyInt16 seg_uend[8] = {
+    0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF
+};
 
 static PyInt16
-search(PyInt16 val, PyInt16 *table, int size)
+search(PyInt16 val, const PyInt16 *table, int size)
 {
     int i;
 
@@ -70,7 +72,7 @@ search(PyInt16 val, PyInt16 *table, int size)
 #define st_ulaw2linear16(uc) (_st_ulaw2linear16[uc])
 #define st_alaw2linear16(uc) (_st_alaw2linear16[uc])
 
-static PyInt16 _st_ulaw2linear16[256] = {
+static const PyInt16 _st_ulaw2linear16[256] = {
     -32124,  -31100,  -30076,  -29052,  -28028,  -27004,  -25980,
     -24956,  -23932,  -22908,  -21884,  -20860,  -19836,  -18812,
     -17788,  -16764,  -15996,  -15484,  -14972,  -14460,  -13948,
@@ -176,7 +178,7 @@ st_14linear2ulaw(PyInt16 pcm_val)       /* 2's complement (14-bit range) */
 
 }
 
-static PyInt16 _st_alaw2linear16[256] = {
+static const PyInt16 _st_alaw2linear16[256] = {
      -5504,   -5248,   -6016,   -5760,   -4480,   -4224,   -4992,
      -4736,   -7552,   -7296,   -8064,   -7808,   -6528,   -6272,
      -7040,   -6784,   -2752,   -2624,   -3008,   -2880,   -2240,
@@ -270,12 +272,12 @@ st_linear2alaw(PyInt16 pcm_val) /* 2's complement (13-bit range) */
 /* End of code taken from sox */
 
 /* Intel ADPCM step variation table */
-static int indexTable[16] = {
+static const int indexTable[16] = {
     -1, -1, -1, -1, 2, 4, 6, 8,
     -1, -1, -1, -1, 2, 4, 6, 8,
 };
 
-static int stepsizeTable[89] = {
+static const int stepsizeTable[89] = {
     7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
     19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
     50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
index ccd81faf94cebf6b7444d43eeb1c2301f5cfe4e4..9df48dad44450ab77f39b6335479b5c7f3641a04 100644 (file)
@@ -74,7 +74,7 @@ static PyObject *Incomplete;
 #define SKIP 0x7E
 #define FAIL 0x7D
 
-static unsigned char table_a2b_hqx[256] = {
+static const unsigned char table_a2b_hqx[256] = {
 /*       ^@    ^A    ^B    ^C    ^D    ^E    ^F    ^G   */
 /* 0*/  FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL,
 /*       \b    \t    \n    ^K    ^L    \r    ^N    ^O   */
@@ -125,10 +125,10 @@ static unsigned char table_a2b_hqx[256] = {
     FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL, FAIL,
 };
 
-static unsigned char table_b2a_hqx[] =
+static const unsigned char table_b2a_hqx[] =
 "!\"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr";
 
-static char table_a2b_base64[] = {
+static const char table_a2b_base64[] = {
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
@@ -144,12 +144,12 @@ static char table_a2b_base64[] = {
 /* Max binary chunk size; limited only by available memory */
 #define BASE64_MAXBIN ((PY_SSIZE_T_MAX - 3) / 2)
 
-static unsigned char table_b2a_base64[] =
+static const unsigned char table_b2a_base64[] =
 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 
 
-static unsigned short crctab_hqx[256] = {
+static const unsigned short crctab_hqx[256] = {
     0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
     0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
     0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
@@ -977,7 +977,7 @@ binascii_crc_hqx_impl(PyModuleDef *module, Py_buffer *data, unsigned int crc)
      using byte-swap instructions.
 ********************************************************************/
 
-static unsigned int crc_32_tab[256] = {
+static const unsigned int crc_32_tab[256] = {
 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U,
 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U,
 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U,
@@ -1201,7 +1201,7 @@ binascii_unhexlify_impl(PyModuleDef *module, Py_buffer *hexstr)
     return binascii_a2b_hex_impl(module, hexstr);
 }
 
-static int table_hex[128] = {
+static const int table_hex[128] = {
   -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
   -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
   -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
index e2a2edf82d3c91b19b12f9e7d5a528d6e7181078..33d70784aba7537b375af4ac76187ea741c3685d 100644 (file)
@@ -136,7 +136,7 @@ static int get_addr(const char *, int, struct addrinfo **,
                         struct addrinfo *, int);
 static int str_isnumber(const char *);
 
-static char *ai_errlist[] = {
+static const char * const ai_errlist[] = {
     "success.",
     "address family for hostname not supported.",       /* EAI_ADDRFAMILY */
     "temporary failure in name resolution.",            /* EAI_AGAIN      */
index 03d292c18b5989f42781c90e0d5100a505a68896..30a0e99dc8b48a6bec002a8e0f91afe6acb56cea 100644 (file)
@@ -477,8 +477,8 @@ calculate_path(void)
 {
     extern wchar_t *Py_GetProgramName(void);
 
-    static wchar_t delimiter[2] = {DELIM, '\0'};
-    static wchar_t separator[2] = {SEP, '\0'};
+    static const wchar_t delimiter[2] = {DELIM, '\0'};
+    static const wchar_t separator[2] = {SEP, '\0'};
     char *_rtpypath = Py_GETENV("PYTHONPATH"); /* XXX use wide version on Windows */
     wchar_t *rtpypath = NULL;
     wchar_t *home = Py_GetPythonHome();
index 0fbdb698e342fba74b220579ae0c27687c9a8d26..4358cc800006323780f809300275f3557ef12cda 100644 (file)
@@ -42,11 +42,11 @@ static int  orig_argc;
 #define PROGRAM_OPTS BASE_OPTS
 
 /* Short usage message (with %s for argv0) */
-static char *usage_line =
+static const char usage_line[] =
 "usage: %ls [option] ... [-c cmd | -m mod | file | -] [arg] ...\n";
 
 /* Long usage message, split into parts < 512 bytes */
-static char *usage_1 = "\
+static const char usage_1[] = "\
 Options and arguments (and corresponding environment variables):\n\
 -b     : issue warnings about str(bytes_instance), str(bytearray_instance)\n\
          and comparing bytes/bytearray with str. (-bb: issue errors)\n\
@@ -56,7 +56,7 @@ Options and arguments (and corresponding environment variables):\n\
 -E     : ignore PYTHON* environment variables (such as PYTHONPATH)\n\
 -h     : print this help message and exit (also --help)\n\
 ";
-static char *usage_2 = "\
+static const char usage_2[] = "\
 -i     : inspect interactively after running script; forces a prompt even\n\
          if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\
 -I     : isolate Python from the user's environment (implies -E and -s)\n\
@@ -67,7 +67,7 @@ static char *usage_2 = "\
 -s     : don't add user site directory to sys.path; also PYTHONNOUSERSITE\n\
 -S     : don't imply 'import site' on initialization\n\
 ";
-static char *usage_3 = "\
+static const char usage_3[] = "\
 -u     : unbuffered binary stdout and stderr, stdin always buffered;\n\
          also PYTHONUNBUFFERED=x\n\
          see man page for details on internal buffering relating to '-u'\n\
@@ -79,7 +79,7 @@ static char *usage_3 = "\
 -x     : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
 -X opt : set implementation-specific option\n\
 ";
-static char *usage_4 = "\
+static const char usage_4[] = "\
 file   : program read from script file\n\
 -      : program read from stdin (default; interactive mode if a tty)\n\
 arg ...: arguments passed to program in sys.argv[1:]\n\n\
@@ -88,14 +88,14 @@ PYTHONSTARTUP: file executed on interactive startup (no default)\n\
 PYTHONPATH   : '%c'-separated list of directories prefixed to the\n\
                default module search path.  The result is sys.path.\n\
 ";
-static char *usage_5 =
+static const char usage_5[] =
 "PYTHONHOME   : alternate <prefix> directory (or <prefix>%c<exec_prefix>).\n"
 "               The default module search path uses %s.\n"
 "PYTHONCASEOK : ignore case in 'import' statements (Windows).\n"
 "PYTHONIOENCODING: Encoding[:errors] used for stdin/stdout/stderr.\n"
 "PYTHONFAULTHANDLER: dump the Python traceback on fatal errors.\n\
 ";
-static char *usage_6 = "\
+static const char usage_6[] = "\
 PYTHONHASHSEED: if this variable is set to 'random', a random value is used\n\
    to seed the hashes of str, bytes and datetime objects.  It can also be\n\
    set to an integer in the range [0,4294967295] to get hash values with a\n\
index 6471b8ee997fcf8ea1f6d5aed201edf82b823985..4c5f2efd0a5d605032add842b68d7c3f07d96494 100644 (file)
@@ -53,7 +53,7 @@ extern grammar _PyParser_Grammar; /* From graminit.c */
 /*  String constants used to initialize module attributes.
  *
  */
-static char parser_copyright_string[] =
+static const char parser_copyright_string[] =
 "Copyright 1995-1996 by Virginia Polytechnic Institute & State\n\
 University, Blacksburg, Virginia, USA, and Fred L. Drake, Jr., Reston,\n\
 Virginia, USA.  Portions copyright 1991-1995 by Stichting Mathematisch\n\
@@ -63,7 +63,7 @@ Centrum, Amsterdam, The Netherlands.";
 PyDoc_STRVAR(parser_doc_string,
 "This is an interface to Python's internal parser.");
 
-static char parser_version_string[] = "0.5";
+static const char parser_version_string[] = "0.5";
 
 
 typedef PyObject* (*SeqMaker) (Py_ssize_t length);
index 7ec1f47e7e58c070b4f809d0a12b2166613703c4..7a2b661e610b9555aea2c4e5e519fc58425817a6 100644 (file)
@@ -9479,7 +9479,7 @@ os__getdiskusage_impl(PyModuleDef *module, Py_UNICODE *path)
  * sufficiently pervasive that it's not worth the loss of readability.
  */
 struct constdef {
-    char *name;
+    const char *name;
     int value;
 };
 
@@ -10822,7 +10822,7 @@ os_getxattr_impl(PyModuleDef *module, path_t *path, path_t *attribute,
     for (i = 0; ; i++) {
         void *ptr;
         ssize_t result;
-        static Py_ssize_t buffer_sizes[] = {128, XATTR_SIZE_MAX, 0};
+        static const Py_ssize_t buffer_sizes[] = {128, XATTR_SIZE_MAX, 0};
         Py_ssize_t buffer_size = buffer_sizes[i];
         if (!buffer_size) {
             path_error(path);
@@ -10988,7 +10988,7 @@ os_listxattr_impl(PyModuleDef *module, path_t *path, int follow_symlinks)
     for (i = 0; ; i++) {
         char *start, *trace, *end;
         ssize_t length;
-        static Py_ssize_t buffer_sizes[] = { 256, XATTR_LIST_MAX, 0 };
+        static const Py_ssize_t buffer_sizes[] = { 256, XATTR_LIST_MAX, 0 };
         Py_ssize_t buffer_size = buffer_sizes[i];
         if (!buffer_size) {
             /* ERANGE */
@@ -12821,7 +12821,7 @@ static struct PyModuleDef posixmodule = {
 };
 
 
-static char *have_functions[] = {
+static const char * const have_functions[] = {
 
 #ifdef HAVE_FACCESSAT
     "HAVE_FACCESSAT",
@@ -12956,7 +12956,7 @@ INITFUNC(void)
 {
     PyObject *m, *v;
     PyObject *list;
-    char **trace;
+    const char * const *trace;
 
 #if defined(HAVE_SYMLINK) && defined(MS_WINDOWS)
     win32_can_symlink = enable_symlink();
index b3ac8073a916cc30a4354b8b90d5401728a1d1b0..70f2db0760b75c6432ee995c14d3ea1408c526e8 100644 (file)
@@ -1842,7 +1842,7 @@ kqueue_event_init(kqueue_event_Object *self, PyObject *args, PyObject *kwds)
     PyObject *pfd;
     static char *kwlist[] = {"ident", "filter", "flags", "fflags",
                              "data", "udata", NULL};
-    static char *fmt = "O|hHI" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent";
+    static const char fmt[] = "O|hHI" DATA_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent";
 
     EV_SET(&(self->e), 0, EVFILT_READ, EV_ADD, 0, 0, 0); /* defaults */
 
index d2caacdc6dd8dd968bf8f59d626630202b09f345..31f0ce5818a6108cb53ce8df9b7157680a4ebab2 100644 (file)
@@ -732,10 +732,10 @@ _asctime(struct tm *timeptr)
 {
     /* Inspired by Open Group reference implementation available at
      * http://pubs.opengroup.org/onlinepubs/009695399/functions/asctime.html */
-    static char wday_name[7][4] = {
+    static const char wday_name[7][4] = {
         "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
     };
-    static char mon_name[12][4] = {
+    static const char mon_name[12][4] = {
         "Jan", "Feb", "Mar", "Apr", "May", "Jun",
         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
     };
index fe4e90822a3096f3840d02029b20e1baec4de9b7..7d518fa2573c9dcf0bd54739868af1b7dbc7c01c 100644 (file)
@@ -884,7 +884,7 @@ _gethash(const char *s, int len, int scale)
     return h;
 }
 
-static char *hangul_syllables[][3] = {
+static const char * const hangul_syllables[][3] = {
     { "G",  "A",   ""   },
     { "GG", "AE",  "G"  },
     { "N",  "YA",  "GG" },
@@ -1057,7 +1057,7 @@ find_syllable(const char *str, int *len, int *pos, int count, int column)
     int i, len1;
     *len = -1;
     for (i = 0; i < count; i++) {
-        char *s = hangul_syllables[i][column];
+        const char *s = hangul_syllables[i][column];
         len1 = Py_SAFE_DOWNCAST(strlen(s), size_t, int);
         if (len1 <= *len)
             continue;
index e1718eafcdbf77f1dc3f7d8cc8b37257008643e7..417a97db85dfcbe66e2b786b97901cb7ae99b808 100644 (file)
@@ -644,7 +644,7 @@ PyObject_Bytes(PyObject *v)
 /* Map rich comparison operators to their swapped version, e.g. LT <--> GT */
 int _Py_SwappedOp[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE};
 
-static char *opstrings[] = {"<", "<=", "==", "!=", ">", ">="};
+static const char * const opstrings[] = {"<", "<=", "==", "!=", ">", ">="};
 
 /* Perform a rich comparison, raising TypeError when the requested comparison
    operator is not supported. */
index 720973816ecbde70c1e6d38d253b03ad79cb6912..e315cbace508b446c4f2febb7ae0df8367c6db99 100644 (file)
@@ -4,9 +4,9 @@
 #include "Python.h"
 #include "structmember.h"
 
-static char visible_length_key[] = "n_sequence_fields";
-static char real_length_key[] = "n_fields";
-static char unnamed_fields_key[] = "n_unnamed_fields";
+static const char visible_length_key[] = "n_sequence_fields";
+static const char real_length_key[] = "n_fields";
+static const char unnamed_fields_key[] = "n_unnamed_fields";
 
 /* Fields with this name have only a field index, not a field name.
    They are only allowed for indices < n_visible_fields. */
index 341e18c455f78f34df52576291a79312ca866c7f..b4d23b257a7671161999913c776fb215b7156b0f 100644 (file)
@@ -2690,7 +2690,7 @@ error:
     return NULL;
 }
 
-static short slotoffsets[] = {
+static const short slotoffsets[] = {
     -1, /* invalid slot */
 #include "typeslots.inc"
 };
index a985d6fb422fd046c9233341314fb61bdfb211c1..fef184ac942c936f84e24f53fb3acc7659aef96c 100644 (file)
@@ -272,7 +272,7 @@ raise_encode_exception(PyObject **exceptionObject,
                        const char *reason);
 
 /* Same for linebreaks */
-static unsigned char ascii_linebreak[] = {
+static const unsigned char ascii_linebreak[] = {
     0, 0, 0, 0, 0, 0, 0, 0,
 /*         0x000A, * LINE FEED */
 /*         0x000B, * LINE TABULATION */
@@ -4135,7 +4135,7 @@ unicode_decode_call_errorhandler_wchar(
     Py_ssize_t *endinpos, PyObject **exceptionObject, const char **inptr,
     PyObject **output, Py_ssize_t *outpos)
 {
-    static char *argparse = "O!n;decoding error handler must return (str, int) tuple";
+    static const char *argparse = "O!n;decoding error handler must return (str, int) tuple";
 
     PyObject *restuple = NULL;
     PyObject *repunicode = NULL;
@@ -4243,7 +4243,7 @@ unicode_decode_call_errorhandler_writer(
     Py_ssize_t *endinpos, PyObject **exceptionObject, const char **inptr,
     _PyUnicodeWriter *writer /* PyObject **output, Py_ssize_t *outpos */)
 {
-    static char *argparse = "O!n;decoding error handler must return (str, int) tuple";
+    static const char *argparse = "O!n;decoding error handler must return (str, int) tuple";
 
     PyObject *restuple = NULL;
     PyObject *repunicode = NULL;
@@ -6560,7 +6560,7 @@ unicode_encode_call_errorhandler(const char *errors,
                                  Py_ssize_t startpos, Py_ssize_t endpos,
                                  Py_ssize_t *newpos)
 {
-    static char *argparse = "On;encoding error handler must return (str/bytes, int) tuple";
+    static const char *argparse = "On;encoding error handler must return (str/bytes, int) tuple";
     Py_ssize_t len;
     PyObject *restuple;
     PyObject *resunicode;
@@ -8572,7 +8572,7 @@ unicode_translate_call_errorhandler(const char *errors,
                                     Py_ssize_t startpos, Py_ssize_t endpos,
                                     Py_ssize_t *newpos)
 {
-    static char *argparse = "O!n;translating error handler must return (str, int) tuple";
+    static const char *argparse = "O!n;translating error handler must return (str, int) tuple";
 
     Py_ssize_t i_newpos;
     PyObject *restuple;
@@ -12156,7 +12156,7 @@ unicode_lower(PyObject *self)
 #define BOTHSTRIP 2
 
 /* Arrays indexed by above */
-static const char *stripformat[] = {"|O:lstrip", "|O:rstrip", "|O:strip"};
+static const char * const stripformat[] = {"|O:lstrip", "|O:rstrip", "|O:strip"};
 
 #define STRIPNAME(i) (stripformat[i]+3)
 
index 629dee565cd9266ad50e9f309252cfb6005261d5..ebe9495184e2222cd443e6e2ed0b4972f1b1eb5a 100644 (file)
@@ -161,10 +161,10 @@ PyParser_ParseFileFlagsEx(FILE *fp, const char *filename,
 
 #ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
 #if 0
-static char with_msg[] =
+static const char with_msg[] =
 "%s:%d: Warning: 'with' will become a reserved keyword in Python 2.6\n";
 
-static char as_msg[] =
+static const char as_msg[] =
 "%s:%d: Warning: 'as' will become a reserved keyword in Python 2.6\n";
 
 static void
index f3031aea0b6d141d884827614b77ff6b3d28d665..6ecb311602152daea8a483d31e8b3cee654d863f 100644 (file)
@@ -134,7 +134,7 @@ addnfa(nfagrammar *gr, char *name)
 
 #ifdef Py_DEBUG
 
-static char REQNFMT[] = "metacompile: less than %d children\n";
+static const char REQNFMT[] = "metacompile: less than %d children\n";
 
 #define REQN(i, count) do { \
     if (i < count) { \
index 77ebc83e805a954962c577226fbe9bf1c5b4943c..328ee5d9141815277f82da188f0045ba9bb213eb 100644 (file)
@@ -870,7 +870,7 @@ get_operator(const node *n)
     }
 }
 
-static const char* FORBIDDEN[] = {
+static const char * const FORBIDDEN[] = {
     "None",
     "True",
     "False",
@@ -887,7 +887,7 @@ forbidden_name(struct compiling *c, identifier name, const node *n,
         return 1;
     }
     if (full_checks) {
-        const char **p;
+        const char * const *p;
         for (p = FORBIDDEN; *p; p++) {
             if (PyUnicode_CompareWithASCIIString(name, *p) == 0) {
                 ast_error(c, n, "assignment to keyword");
index 3da546ed0709e5be7984857045ac000f848eee14..3121cd6b9b4508b56f12c130ae7ccb53cd5871a7 100644 (file)
@@ -747,7 +747,7 @@ pow5mult(Bigint *b, int k)
 {
     Bigint *b1, *p5, *p51;
     int i;
-    static int p05[3] = { 5, 25, 125 };
+    static const int p05[3] = { 5, 25, 125 };
 
     if ((i = k & 3)) {
         b = multadd(b, p05[i-1], 0);
@@ -803,7 +803,7 @@ pow5mult(Bigint *b, int k)
 {
     Bigint *b1, *p5, *p51;
     int i;
-    static int p05[3] = { 5, 25, 125 };
+    static const int p05[3] = { 5, 25, 125 };
 
     if ((i = k & 3)) {
         b = multadd(b, p05[i-1], 0);
index 056bb76902597e8b959fa53dcd58386102b10c99..a428fbec809cbec898e4b4d5b8e10f031a399f7b 100644 (file)
@@ -656,7 +656,7 @@ fill_number(_PyUnicodeWriter *writer, const NumberFieldWidths *spec,
     return 0;
 }
 
-static char no_grouping[1] = {CHAR_MAX};
+static const char no_grouping[1] = {CHAR_MAX};
 
 /* Find the decimal point character(s?), thousands_separator(s?), and
    grouping description, either for the current locale if type is
index edf030d87ae9d359947a767c15aa0ed265525a39..8d7bfe906f79e21d39d3eb3aa780626dc069644e 100644 (file)
@@ -320,7 +320,7 @@ PyImport_GetModuleDict(void)
 
 
 /* List of names to clear in sys */
-static char* sys_deletes[] = {
+static const char * const sys_deletes[] = {
     "path", "argv", "ps1", "ps2",
     "last_type", "last_value", "last_traceback",
     "path_hooks", "path_importer_cache", "meta_path",
@@ -330,7 +330,7 @@ static char* sys_deletes[] = {
     NULL
 };
 
-static char* sys_files[] = {
+static const char * const sys_files[] = {
     "stdin", "__stdin__",
     "stdout", "__stdout__",
     "stderr", "__stderr__",
@@ -347,7 +347,7 @@ PyImport_Cleanup(void)
     PyInterpreterState *interp = PyThreadState_GET()->interp;
     PyObject *modules = interp->modules;
     PyObject *weaklist = NULL;
-    char **p;
+    const char * const *p;
 
     if (modules == NULL)
         return; /* Already done */
index 1aa585d5e811cabbb8de67003a698672b5f2798b..ac03289c4d23f1f91d6cebac51a434a372d9860f 100644 (file)
@@ -23,8 +23,8 @@ extern dl_funcptr _PyImport_FindSharedFuncptr(const char *prefix,
                                               const char *pathname, FILE *fp);
 #endif
 
-static const char *ascii_only_prefix = "PyInit";
-static const char *nonascii_prefix = "PyInitU";
+static const char * const ascii_only_prefix = "PyInit";
+static const char * const nonascii_prefix = "PyInitU";
 
 /* Get the variable part of a module's export symbol name.
  * Returns a bytes instance. For non-ASCII-named modules, the name is
index 98429d4b428dc6d93af6ad3dd46ed7a2140deecc..a85790e1bfe7ec5885ab8b3bc599ae56fc9bd6e0 100644 (file)
@@ -17,7 +17,7 @@
  * smallmax[base] is the largest unsigned long i such that
  * i * base doesn't overflow unsigned long.
  */
-static unsigned long smallmax[] = {
+static const unsigned long smallmax[] = {
     0, /* bases 0 and 1 are invalid */
     0,
     ULONG_MAX / 2,
@@ -62,14 +62,14 @@ static unsigned long smallmax[] = {
  * Note that this is pessimistic if sizeof(long) > 4.
  */
 #if SIZEOF_LONG == 4
-static int digitlimit[] = {
+static const int digitlimit[] = {
     0,  0, 32, 20, 16, 13, 12, 11, 10, 10,  /*  0 -  9 */
     9,  9,  8,  8,  8,  8,  8,  7,  7,  7,  /* 10 - 19 */
     7,  7,  7,  7,  6,  6,  6,  6,  6,  6,  /* 20 - 29 */
     6,  6,  6,  6,  6,  6,  6};             /* 30 - 36 */
 #elif SIZEOF_LONG == 8
 /* [int(math.floor(math.log(2**64, i))) for i in range(2, 37)] */
-static int digitlimit[] = {
+static const int digitlimit[] = {
          0,   0, 64, 40, 32, 27, 24, 22, 21, 20,  /*  0 -  9 */
     19,  18, 17, 17, 16, 16, 16, 15, 15, 15,  /* 10 - 19 */
     14,  14, 14, 14, 13, 13, 13, 13, 13, 13,  /* 20 - 29 */
index 209c9086c87b9c061cf015ea371275f9be12f795..5f3af92dca662db98416f7bfebb2264cfcecc3e2 100644 (file)
@@ -881,12 +881,12 @@ PyAPI_FUNC(char *) PyOS_double_to_string(double val,
 #define OFS_E 2
 
 /* The lengths of these are known to the code below, so don't change them */
-static char *lc_float_strings[] = {
+static const char * const lc_float_strings[] = {
     "inf",
     "nan",
     "e",
 };
-static char *uc_float_strings[] = {
+static const char * const uc_float_strings[] = {
     "INF",
     "NAN",
     "E",
@@ -925,7 +925,8 @@ static char *
 format_float_short(double d, char format_code,
                    int mode, int precision,
                    int always_add_sign, int add_dot_0_if_integer,
-                   int use_alt_formatting, char **float_strings, int *type)
+                   int use_alt_formatting, const char * const *float_strings,
+                   int *type)
 {
     char *buf = NULL;
     char *p = NULL;
@@ -1176,7 +1177,7 @@ PyAPI_FUNC(char *) PyOS_double_to_string(double val,
                                          int flags,
                                          int *type)
 {
-    char **float_strings = lc_float_strings;
+    const char * const *float_strings = lc_float_strings;
     int mode;
 
     /* Validate format_code, and map upper and lower case. Compute the
index 1a5dab5f3a0b56fb4806acf80fd033a723c40faa..cfe197b25b9efea0f8b1f13918f89911f0cb1371 100644 (file)
@@ -785,11 +785,11 @@ print_exception(PyObject *f, PyObject *value)
         PyErr_Clear();
 }
 
-static const char *cause_message =
+static const char cause_message[] =
     "\nThe above exception was the direct cause "
     "of the following exception:\n\n";
 
-static const char *context_message =
+static const char context_message[] =
     "\nDuring handling of the above exception, "
     "another exception occurred:\n\n";
 
index e0aa233ca9cb94d12ea5d813a81a4bf07a58710c..f784f756d598376bee853e4b1cb3ceaa3058ea0f 100644 (file)
@@ -346,8 +346,10 @@ static PyObject *whatstrings[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
 static int
 trace_init(void)
 {
-    static char *whatnames[7] = {"call", "exception", "line", "return",
-                                    "c_call", "c_exception", "c_return"};
+    static const char * const whatnames[7] = {
+        "call", "exception", "line", "return",
+        "c_call", "c_exception", "c_return"
+    };
     PyObject *name;
     int i;
     for (i = 0; i < 7; ++i) {