diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-12-12 11:55:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-12 11:55:04 (GMT) |
commit | 4ae06c5337e01bdde28bce57b6b9166ad50947e3 (patch) | |
tree | 5e9e92f616bc452eb4096b56ea373fa8b46d2510 /Python | |
parent | 5ce0a2a100909104836f53a2c8823006ec46f8ad (diff) | |
download | cpython-4ae06c5337e01bdde28bce57b6b9166ad50947e3.zip cpython-4ae06c5337e01bdde28bce57b6b9166ad50947e3.tar.gz cpython-4ae06c5337e01bdde28bce57b6b9166ad50947e3.tar.bz2 |
bpo-32241: Add the const qualifire to declarations of umodifiable strings. (#4748)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bootstrap_hash.c | 8 | ||||
-rw-r--r-- | Python/dynamic_annotations.c | 2 | ||||
-rw-r--r-- | Python/frozenmain.c | 2 | ||||
-rw-r--r-- | Python/pathconfig.c | 4 | ||||
-rw-r--r-- | Python/pylifecycle.c | 7 | ||||
-rw-r--r-- | Python/sysmodule.c | 6 | ||||
-rw-r--r-- | Python/thread.c | 2 |
7 files changed, 16 insertions, 15 deletions
diff --git a/Python/bootstrap_hash.c b/Python/bootstrap_hash.c index 610541d..2762f46 100644 --- a/Python/bootstrap_hash.c +++ b/Python/bootstrap_hash.c @@ -533,16 +533,16 @@ _PyOS_URandomNonblock(void *buffer, Py_ssize_t size) return pyurandom(buffer, size, 0, 1); } -int Py_ReadHashSeed(char *seed_text, +int Py_ReadHashSeed(const char *seed_text, int *use_hash_seed, unsigned long *hash_seed) { Py_BUILD_ASSERT(sizeof(_Py_HashSecret_t) == sizeof(_Py_HashSecret.uc)); /* Convert a text seed to a numeric one */ if (seed_text && *seed_text != '\0' && strcmp(seed_text, "random") != 0) { - char *endptr = seed_text; + const char *endptr = seed_text; unsigned long seed; - seed = strtoul(seed_text, &endptr, 10); + seed = strtoul(seed_text, (char **)&endptr, 10); if (*endptr != '\0' || seed > 4294967295UL || (errno == ERANGE && seed == ULONG_MAX)) @@ -604,7 +604,7 @@ init_hash_secret(int use_hash_seed, _PyInitError _Py_HashRandomization_Init(_PyCoreConfig *core_config) { - char *seed_text; + const char *seed_text; int use_hash_seed = core_config->use_hash_seed; unsigned long hash_seed = core_config->hash_seed; diff --git a/Python/dynamic_annotations.c b/Python/dynamic_annotations.c index 10511da..7febaa0 100644 --- a/Python/dynamic_annotations.c +++ b/Python/dynamic_annotations.c @@ -120,7 +120,7 @@ static int GetRunningOnValgrind(void) { #endif #ifndef _MSC_VER - char *running_on_valgrind_str = getenv("RUNNING_ON_VALGRIND"); + const char *running_on_valgrind_str = getenv("RUNNING_ON_VALGRIND"); if (running_on_valgrind_str) { return strcmp(running_on_valgrind_str, "0") != 0; } diff --git a/Python/frozenmain.c b/Python/frozenmain.c index 77602d7..a3b6196 100644 --- a/Python/frozenmain.c +++ b/Python/frozenmain.c @@ -23,7 +23,7 @@ Py_FrozenMain(int argc, char **argv) exit(1); } - char *p; + const char *p; int i, n, sts = 1; int inspect = 0; int unbuffered = 0; diff --git a/Python/pathconfig.c b/Python/pathconfig.c index 6a03f7d..53ddfc9 100644 --- a/Python/pathconfig.c +++ b/Python/pathconfig.c @@ -168,7 +168,7 @@ Py_SetPath(const wchar_t *path) void -Py_SetPythonHome(wchar_t *home) +Py_SetPythonHome(const wchar_t *home) { if (home == NULL) { return; @@ -189,7 +189,7 @@ Py_SetPythonHome(wchar_t *home) void -Py_SetProgramName(wchar_t *program_name) +Py_SetProgramName(const wchar_t *program_name) { if (program_name == NULL || program_name[0] == L'\0') { return; diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 0b3aa98..fdb09d9 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -414,7 +414,7 @@ static _LocaleCoercionTarget _TARGET_LOCALES[] = { {NULL} }; -static char * +static const char * get_default_standard_stream_error_handler(void) { const char *ctype_loc = setlocale(LC_CTYPE, NULL); @@ -440,7 +440,7 @@ get_default_standard_stream_error_handler(void) } #ifdef PY_COERCE_C_LOCALE -static const char *_C_LOCALE_COERCION_WARNING = +static const char _C_LOCALE_COERCION_WARNING[] = "Python detected LC_CTYPE=C: LC_CTYPE coerced to %.20s (set another locale " "or PYTHONCOERCECLOCALE=0 to disable this locale coercion behavior).\n"; @@ -1757,7 +1757,8 @@ init_sys_streams(void) PyObject *std = NULL; int fd; PyObject * encoding_attr; - char *pythonioencoding = NULL, *encoding, *errors; + char *pythonioencoding = NULL; + const char *encoding, *errors; _PyInitError res = _Py_INIT_OK(); /* Hack to avoid a nasty recursion issue when Python is invoked diff --git a/Python/sysmodule.c b/Python/sysmodule.c index eeeaa72..f10099b 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -100,7 +100,7 @@ static PyObject * sys_breakpointhook(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *keywords) { assert(!PyErr_Occurred()); - char *envar = Py_GETENV("PYTHONBREAKPOINT"); + const char *envar = Py_GETENV("PYTHONBREAKPOINT"); if (envar == NULL || strlen(envar) == 0) { envar = "pdb.set_trace"; @@ -109,8 +109,8 @@ sys_breakpointhook(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject * /* The breakpoint is explicitly no-op'd. */ Py_RETURN_NONE; } - char *last_dot = strrchr(envar, '.'); - char *attrname = NULL; + const char *last_dot = strrchr(envar, '.'); + const char *attrname = NULL; PyObject *modulepath = NULL; if (last_dot == NULL) { diff --git a/Python/thread.c b/Python/thread.c index 7eac836..0774384 100644 --- a/Python/thread.c +++ b/Python/thread.c @@ -61,7 +61,7 @@ void PyThread_init_thread(void) { #ifdef Py_DEBUG - char *p = Py_GETENV("PYTHONTHREADDEBUG"); + const char *p = Py_GETENV("PYTHONTHREADDEBUG"); if (p) { if (*p) |