Add the const qualifier to "char *" variables that refer to literal strings. (#4370)
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 6215a63..8eac0af 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1942,7 +1942,7 @@
/* If we're interactive, use (GNU) readline */
if (tty) {
PyObject *po = NULL;
- char *promptstr;
+ const char *promptstr;
char *s = NULL;
PyObject *stdin_encoding = NULL, *stdin_errors = NULL;
PyObject *stdout_encoding = NULL, *stdout_errors = NULL;
diff --git a/Python/compile.c b/Python/compile.c
index 58a708c..a3ea60d 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -4846,7 +4846,7 @@
static int
compiler_visit_slice(struct compiler *c, slice_ty s, expr_context_ty ctx)
{
- char * kindname = NULL;
+ const char * kindname = NULL;
switch (s->kind) {
case Index_kind:
kindname = "index";
diff --git a/Python/pyhash.c b/Python/pyhash.c
index 8a6bd60..aa49eeb 100644
--- a/Python/pyhash.c
+++ b/Python/pyhash.c
@@ -196,7 +196,7 @@
#ifdef Py_HASH_STATS
int i;
Py_ssize_t total = 0;
- char *fmt = "%2i %8" PY_FORMAT_SIZE_T "d %8" PY_FORMAT_SIZE_T "d\n";
+ const char *fmt = "%2i %8" PY_FORMAT_SIZE_T "d %8" PY_FORMAT_SIZE_T "d\n";
fprintf(stderr, "len calls total\n");
for (i = 1; i <= Py_HASH_STATS_MAX; i++) {
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index f19d239..9bf9363 100644
--- a/Python/pystrtod.c
+++ b/Python/pystrtod.c
@@ -597,7 +597,8 @@
ensure_decimal_point(char* buffer, size_t buf_size, int precision)
{
int digit_count, insert_count = 0, convert_to_exp = 0;
- char *chars_to_insert, *digits_start;
+ const char *chars_to_insert;
+ char *digits_start;
/* search for the first non-digit character */
char *p = buffer;
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 17ec182..3d63186 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1300,7 +1300,7 @@
{
PyObject *v, *w, *errtype, *errtext;
PyObject *msg_obj = NULL;
- char *msg = NULL;
+ const char *msg = NULL;
int offset = err->offset;
errtype = PyExc_SyntaxError;