mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
bpo-32241: Add the const qualifire to declarations of umodifiable strings. (#4748)
This commit is contained in:
parent
5ce0a2a100
commit
4ae06c5337
15 changed files with 59 additions and 56 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue