bpo-32241: Add the const qualifire to declarations of umodifiable strings. (#4748)
This commit is contained in:
parent
5ce0a2a100
commit
4ae06c5337
|
@ -338,7 +338,7 @@ Process-wide parameters
|
||||||
.. versionadded:: 3.4
|
.. versionadded:: 3.4
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: void Py_SetProgramName(wchar_t *name)
|
.. c:function:: void Py_SetProgramName(const wchar_t *name)
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
single: Py_Initialize()
|
single: Py_Initialize()
|
||||||
|
@ -605,7 +605,7 @@ Process-wide parameters
|
||||||
.. versionchanged:: 3.4 The *updatepath* value depends on :option:`-I`.
|
.. versionchanged:: 3.4 The *updatepath* value depends on :option:`-I`.
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: void Py_SetPythonHome(wchar_t *home)
|
.. c:function:: void Py_SetPythonHome(const wchar_t *home)
|
||||||
|
|
||||||
Set the default "home" directory, that is, the location of the standard
|
Set the default "home" directory, that is, the location of the standard
|
||||||
Python libraries. See :envvar:`PYTHONHOME` for the meaning of the
|
Python libraries. See :envvar:`PYTHONHOME` for the meaning of the
|
||||||
|
|
|
@ -37,10 +37,10 @@ typedef struct {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
PyAPI_FUNC(void) Py_SetProgramName(wchar_t *);
|
PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *);
|
||||||
PyAPI_FUNC(wchar_t *) Py_GetProgramName(void);
|
PyAPI_FUNC(wchar_t *) Py_GetProgramName(void);
|
||||||
|
|
||||||
PyAPI_FUNC(void) Py_SetPythonHome(wchar_t *);
|
PyAPI_FUNC(void) Py_SetPythonHome(const wchar_t *);
|
||||||
PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
|
PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
|
||||||
|
|
||||||
#ifndef Py_LIMITED_API
|
#ifndef Py_LIMITED_API
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
:c:func:`Py_SetProgramName` and :c:func:`Py_SetPythonHome` now take the
|
||||||
|
``const wchar *`` arguments instead of ``wchar *``.
|
|
@ -251,7 +251,7 @@ getaddrinfo(const char*hostname, const char*servname,
|
||||||
if (firsttime) {
|
if (firsttime) {
|
||||||
/* translator hack */
|
/* translator hack */
|
||||||
{
|
{
|
||||||
char *q = getenv("GAI");
|
const char *q = getenv("GAI");
|
||||||
if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
|
if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
|
||||||
translate = YES;
|
translate = YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -910,7 +910,7 @@ calculate_init(PyCalculatePath *calculate,
|
||||||
const _PyMainInterpreterConfig *main_config)
|
const _PyMainInterpreterConfig *main_config)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
char *path = getenv("PATH");
|
const char *path = getenv("PATH");
|
||||||
if (path) {
|
if (path) {
|
||||||
calculate->path_env = Py_DecodeLocale(path, &len);
|
calculate->path_env = Py_DecodeLocale(path, &len);
|
||||||
if (!calculate->path_env) {
|
if (!calculate->path_env) {
|
||||||
|
|
|
@ -154,10 +154,10 @@ pymain_usage(int error, const wchar_t* program)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char*
|
static const char*
|
||||||
pymain_get_env_var(const char *name)
|
pymain_get_env_var(const char *name)
|
||||||
{
|
{
|
||||||
char *var = Py_GETENV(name);
|
const char *var = Py_GETENV(name);
|
||||||
if (var && var[0] != '\0') {
|
if (var && var[0] != '\0') {
|
||||||
return var;
|
return var;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ pymain_get_env_var(const char *name)
|
||||||
static void
|
static void
|
||||||
pymain_run_startup(PyCompilerFlags *cf)
|
pymain_run_startup(PyCompilerFlags *cf)
|
||||||
{
|
{
|
||||||
char *startup = pymain_get_env_var("PYTHONSTARTUP");
|
const char *startup = pymain_get_env_var("PYTHONSTARTUP");
|
||||||
if (startup == NULL) {
|
if (startup == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -542,7 +542,7 @@ error:
|
||||||
|
|
||||||
|
|
||||||
static wchar_t*
|
static wchar_t*
|
||||||
pymain_wstrdup(_PyMain *pymain, wchar_t *str)
|
pymain_wstrdup(_PyMain *pymain, const wchar_t *str)
|
||||||
{
|
{
|
||||||
wchar_t *str2 = _PyMem_RawWcsdup(str);
|
wchar_t *str2 = _PyMem_RawWcsdup(str);
|
||||||
if (str2 == NULL) {
|
if (str2 == NULL) {
|
||||||
|
@ -554,7 +554,7 @@ pymain_wstrdup(_PyMain *pymain, wchar_t *str)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pymain_optlist_append(_PyMain *pymain, _Py_OptList *list, wchar_t *str)
|
pymain_optlist_append(_PyMain *pymain, _Py_OptList *list, const wchar_t *str)
|
||||||
{
|
{
|
||||||
wchar_t *str2 = pymain_wstrdup(pymain, str);
|
wchar_t *str2 = pymain_wstrdup(pymain, str);
|
||||||
if (str2 == NULL) {
|
if (str2 == NULL) {
|
||||||
|
@ -802,7 +802,7 @@ pymain_warnings_envvar(_PyMain *pymain)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
wchar_t *wp;
|
const wchar_t *wp;
|
||||||
|
|
||||||
if ((wp = _wgetenv(L"PYTHONWARNINGS")) && *wp != L'\0') {
|
if ((wp = _wgetenv(L"PYTHONWARNINGS")) && *wp != L'\0') {
|
||||||
wchar_t *warning, *context = NULL;
|
wchar_t *warning, *context = NULL;
|
||||||
|
@ -824,7 +824,7 @@ pymain_warnings_envvar(_PyMain *pymain)
|
||||||
PyMem_RawFree(buf);
|
PyMem_RawFree(buf);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
char *p = pymain_get_env_var("PYTHONWARNINGS");
|
const char *p = pymain_get_env_var("PYTHONWARNINGS");
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
char *buf, *oldloc;
|
char *buf, *oldloc;
|
||||||
|
|
||||||
|
@ -909,7 +909,7 @@ config_get_program_name(_PyMainInterpreterConfig *config)
|
||||||
assert(config->program_name == NULL);
|
assert(config->program_name == NULL);
|
||||||
|
|
||||||
/* If Py_SetProgramName() was called, use its value */
|
/* If Py_SetProgramName() was called, use its value */
|
||||||
wchar_t *program_name = _Py_path_config.program_name;
|
const wchar_t *program_name = _Py_path_config.program_name;
|
||||||
if (program_name != NULL) {
|
if (program_name != NULL) {
|
||||||
config->program_name = _PyMem_RawWcsdup(program_name);
|
config->program_name = _PyMem_RawWcsdup(program_name);
|
||||||
if (config->program_name == NULL) {
|
if (config->program_name == NULL) {
|
||||||
|
@ -927,7 +927,7 @@ config_get_program_name(_PyMainInterpreterConfig *config)
|
||||||
so the actual executable path is passed in an environment variable.
|
so the actual executable path is passed in an environment variable.
|
||||||
See Lib/plat-mac/bundlebuiler.py for details about the bootstrap
|
See Lib/plat-mac/bundlebuiler.py for details about the bootstrap
|
||||||
script. */
|
script. */
|
||||||
char *p = pymain_get_env_var("PYTHONEXECUTABLE");
|
const char *p = pymain_get_env_var("PYTHONEXECUTABLE");
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
size_t len;
|
size_t len;
|
||||||
wchar_t* program_name = Py_DecodeLocale(p, &len);
|
wchar_t* program_name = Py_DecodeLocale(p, &len);
|
||||||
|
@ -939,7 +939,7 @@ config_get_program_name(_PyMainInterpreterConfig *config)
|
||||||
}
|
}
|
||||||
#ifdef WITH_NEXT_FRAMEWORK
|
#ifdef WITH_NEXT_FRAMEWORK
|
||||||
else {
|
else {
|
||||||
char* pyvenv_launcher = getenv("__PYVENV_LAUNCHER__");
|
const char* pyvenv_launcher = getenv("__PYVENV_LAUNCHER__");
|
||||||
if (pyvenv_launcher && *pyvenv_launcher) {
|
if (pyvenv_launcher && *pyvenv_launcher) {
|
||||||
/* Used by Mac/Tools/pythonw.c to forward
|
/* Used by Mac/Tools/pythonw.c to forward
|
||||||
* the argv0 of the stub executable
|
* the argv0 of the stub executable
|
||||||
|
@ -1289,7 +1289,7 @@ pymain_parse_cmdline(_PyMain *pymain)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static wchar_t*
|
static const wchar_t*
|
||||||
pymain_get_xoption(_PyMain *pymain, wchar_t *name)
|
pymain_get_xoption(_PyMain *pymain, wchar_t *name)
|
||||||
{
|
{
|
||||||
_Py_OptList *list = &pymain->cmdline.xoptions;
|
_Py_OptList *list = &pymain->cmdline.xoptions;
|
||||||
|
@ -1312,11 +1312,11 @@ pymain_get_xoption(_PyMain *pymain, wchar_t *name)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pymain_str_to_int(char *str, int *result)
|
pymain_str_to_int(const char *str, int *result)
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
char *endptr = str;
|
const char *endptr = str;
|
||||||
long value = strtol(str, &endptr, 10);
|
long value = strtol(str, (char **)&endptr, 10);
|
||||||
if (*endptr != '\0' || errno == ERANGE) {
|
if (*endptr != '\0' || errno == ERANGE) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1330,11 +1330,11 @@ pymain_str_to_int(char *str, int *result)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pymain_wstr_to_int(wchar_t *wstr, int *result)
|
pymain_wstr_to_int(const wchar_t *wstr, int *result)
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
wchar_t *endptr = wstr;
|
const wchar_t *endptr = wstr;
|
||||||
long value = wcstol(wstr, &endptr, 10);
|
long value = wcstol(wstr, (wchar_t **)&endptr, 10);
|
||||||
if (*endptr != '\0' || errno == ERANGE) {
|
if (*endptr != '\0' || errno == ERANGE) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1353,7 +1353,7 @@ pymain_init_tracemalloc(_PyMain *pymain)
|
||||||
int nframe;
|
int nframe;
|
||||||
int valid;
|
int valid;
|
||||||
|
|
||||||
char *env = pymain_get_env_var("PYTHONTRACEMALLOC");
|
const char *env = pymain_get_env_var("PYTHONTRACEMALLOC");
|
||||||
if (env) {
|
if (env) {
|
||||||
if (!pymain_str_to_int(env, &nframe)) {
|
if (!pymain_str_to_int(env, &nframe)) {
|
||||||
valid = (nframe >= 1);
|
valid = (nframe >= 1);
|
||||||
|
@ -1369,9 +1369,9 @@ pymain_init_tracemalloc(_PyMain *pymain)
|
||||||
pymain->core_config.tracemalloc = nframe;
|
pymain->core_config.tracemalloc = nframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *xoption = pymain_get_xoption(pymain, L"tracemalloc");
|
const wchar_t *xoption = pymain_get_xoption(pymain, L"tracemalloc");
|
||||||
if (xoption) {
|
if (xoption) {
|
||||||
wchar_t *sep = wcschr(xoption, L'=');
|
const wchar_t *sep = wcschr(xoption, L'=');
|
||||||
if (sep) {
|
if (sep) {
|
||||||
if (!pymain_wstr_to_int(sep + 1, &nframe)) {
|
if (!pymain_wstr_to_int(sep + 1, &nframe)) {
|
||||||
valid = (nframe >= 1);
|
valid = (nframe >= 1);
|
||||||
|
@ -1398,7 +1398,7 @@ pymain_init_tracemalloc(_PyMain *pymain)
|
||||||
static void
|
static void
|
||||||
pymain_set_flag_from_env(int *flag, const char *name)
|
pymain_set_flag_from_env(int *flag, const char *name)
|
||||||
{
|
{
|
||||||
char *var = pymain_get_env_var(name);
|
const char *var = pymain_get_env_var(name);
|
||||||
if (!var) {
|
if (!var) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1449,7 +1449,7 @@ config_get_env_var_dup(wchar_t **dest, wchar_t *wname, char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
wchar_t *var = _wgetenv(wname);
|
const wchar_t *var = _wgetenv(wname);
|
||||||
if (!var || var[0] == '\0') {
|
if (!var || var[0] == '\0') {
|
||||||
*dest = NULL;
|
*dest = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1462,7 +1462,7 @@ config_get_env_var_dup(wchar_t **dest, wchar_t *wname, char *name)
|
||||||
|
|
||||||
*dest = copy;
|
*dest = copy;
|
||||||
#else
|
#else
|
||||||
char *var = getenv(name);
|
const char *var = getenv(name);
|
||||||
if (!var || var[0] == '\0') {
|
if (!var || var[0] == '\0') {
|
||||||
*dest = NULL;
|
*dest = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1167,7 +1167,7 @@ new_arena(void)
|
||||||
static int debug_stats = -1;
|
static int debug_stats = -1;
|
||||||
|
|
||||||
if (debug_stats == -1) {
|
if (debug_stats == -1) {
|
||||||
char *opt = Py_GETENV("PYTHONMALLOCSTATS");
|
const char *opt = Py_GETENV("PYTHONMALLOCSTATS");
|
||||||
debug_stats = (opt != NULL && *opt != '\0');
|
debug_stats = (opt != NULL && *opt != '\0');
|
||||||
}
|
}
|
||||||
if (debug_stats)
|
if (debug_stats)
|
||||||
|
|
|
@ -118,8 +118,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
wchar_t *path_env; /* PATH environment variable */
|
const wchar_t *path_env; /* PATH environment variable */
|
||||||
wchar_t *home; /* PYTHONHOME environment variable */
|
const wchar_t *home; /* PYTHONHOME environment variable */
|
||||||
|
|
||||||
/* Registry key "Software\Python\PythonCore\PythonPath" */
|
/* Registry key "Software\Python\PythonCore\PythonPath" */
|
||||||
wchar_t *machine_path; /* from HKEY_LOCAL_MACHINE */
|
wchar_t *machine_path; /* from HKEY_LOCAL_MACHINE */
|
||||||
|
@ -191,7 +191,7 @@ change_ext(wchar_t *dest, const wchar_t *src, const wchar_t *ext)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
exists(wchar_t *filename)
|
exists(const wchar_t *filename)
|
||||||
{
|
{
|
||||||
return GetFileAttributesW(filename) != 0xFFFFFFFF;
|
return GetFileAttributesW(filename) != 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
@ -286,7 +286,7 @@ gotlandmark(wchar_t *prefix, const wchar_t *landmark)
|
||||||
/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd.
|
/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd.
|
||||||
assumption provided by only caller, calculate_path_impl() */
|
assumption provided by only caller, calculate_path_impl() */
|
||||||
static int
|
static int
|
||||||
search_for_prefix(wchar_t *prefix, wchar_t *argv0_path, const wchar_t *landmark)
|
search_for_prefix(wchar_t *prefix, const wchar_t *argv0_path, const wchar_t *landmark)
|
||||||
{
|
{
|
||||||
/* Search from argv0_path, until landmark is found */
|
/* Search from argv0_path, until landmark is found */
|
||||||
wcscpy_s(prefix, MAXPATHLEN + 1, argv0_path);
|
wcscpy_s(prefix, MAXPATHLEN + 1, argv0_path);
|
||||||
|
@ -523,9 +523,9 @@ get_program_full_path(const _PyMainInterpreterConfig *main_config,
|
||||||
wcsncpy(program_full_path, main_config->program_name, MAXPATHLEN);
|
wcsncpy(program_full_path, main_config->program_name, MAXPATHLEN);
|
||||||
}
|
}
|
||||||
else if (calculate->path_env) {
|
else if (calculate->path_env) {
|
||||||
wchar_t *path = calculate->path_env;
|
const wchar_t *path = calculate->path_env;
|
||||||
while (1) {
|
while (1) {
|
||||||
wchar_t *delim = wcschr(path, DELIM);
|
const wchar_t *delim = wcschr(path, DELIM);
|
||||||
|
|
||||||
if (delim) {
|
if (delim) {
|
||||||
size_t len = delim - path;
|
size_t len = delim - path;
|
||||||
|
@ -845,7 +845,7 @@ calculate_module_search_path(const _PyMainInterpreterConfig *main_config,
|
||||||
/* Calculate size of return buffer */
|
/* Calculate size of return buffer */
|
||||||
size_t bufsz = 0;
|
size_t bufsz = 0;
|
||||||
if (calculate->home != NULL) {
|
if (calculate->home != NULL) {
|
||||||
wchar_t *p;
|
const wchar_t *p;
|
||||||
bufsz = 1;
|
bufsz = 1;
|
||||||
for (p = PYTHONPATH; *p; p++) {
|
for (p = PYTHONPATH; *p; p++) {
|
||||||
if (*p == DELIM) {
|
if (*p == DELIM) {
|
||||||
|
@ -922,8 +922,8 @@ calculate_module_search_path(const _PyMainInterpreterConfig *main_config,
|
||||||
*buf++ = DELIM;
|
*buf++ = DELIM;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wchar_t *p = PYTHONPATH;
|
const wchar_t *p = PYTHONPATH;
|
||||||
wchar_t *q;
|
const wchar_t *q;
|
||||||
size_t n;
|
size_t n;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
q = wcschr(p, DELIM);
|
q = wcschr(p, DELIM);
|
||||||
|
@ -967,10 +967,10 @@ calculate_module_search_path(const _PyMainInterpreterConfig *main_config,
|
||||||
*/
|
*/
|
||||||
if (prefix[0] == L'\0') {
|
if (prefix[0] == L'\0') {
|
||||||
wchar_t lookBuf[MAXPATHLEN+1];
|
wchar_t lookBuf[MAXPATHLEN+1];
|
||||||
wchar_t *look = buf - 1; /* 'buf' is at the end of the buffer */
|
const wchar_t *look = buf - 1; /* 'buf' is at the end of the buffer */
|
||||||
while (1) {
|
while (1) {
|
||||||
Py_ssize_t nchars;
|
Py_ssize_t nchars;
|
||||||
wchar_t *lookEnd = look;
|
const wchar_t *lookEnd = look;
|
||||||
/* 'look' will end up one character before the
|
/* 'look' will end up one character before the
|
||||||
start of the path in question - even if this
|
start of the path in question - even if this
|
||||||
is one character before the start of the buffer
|
is one character before the start of the buffer
|
||||||
|
|
|
@ -533,16 +533,16 @@ _PyOS_URandomNonblock(void *buffer, Py_ssize_t size)
|
||||||
return pyurandom(buffer, size, 0, 1);
|
return pyurandom(buffer, size, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Py_ReadHashSeed(char *seed_text,
|
int Py_ReadHashSeed(const char *seed_text,
|
||||||
int *use_hash_seed,
|
int *use_hash_seed,
|
||||||
unsigned long *hash_seed)
|
unsigned long *hash_seed)
|
||||||
{
|
{
|
||||||
Py_BUILD_ASSERT(sizeof(_Py_HashSecret_t) == sizeof(_Py_HashSecret.uc));
|
Py_BUILD_ASSERT(sizeof(_Py_HashSecret_t) == sizeof(_Py_HashSecret.uc));
|
||||||
/* Convert a text seed to a numeric one */
|
/* Convert a text seed to a numeric one */
|
||||||
if (seed_text && *seed_text != '\0' && strcmp(seed_text, "random") != 0) {
|
if (seed_text && *seed_text != '\0' && strcmp(seed_text, "random") != 0) {
|
||||||
char *endptr = seed_text;
|
const char *endptr = seed_text;
|
||||||
unsigned long seed;
|
unsigned long seed;
|
||||||
seed = strtoul(seed_text, &endptr, 10);
|
seed = strtoul(seed_text, (char **)&endptr, 10);
|
||||||
if (*endptr != '\0'
|
if (*endptr != '\0'
|
||||||
|| seed > 4294967295UL
|
|| seed > 4294967295UL
|
||||||
|| (errno == ERANGE && seed == ULONG_MAX))
|
|| (errno == ERANGE && seed == ULONG_MAX))
|
||||||
|
@ -604,7 +604,7 @@ init_hash_secret(int use_hash_seed,
|
||||||
_PyInitError
|
_PyInitError
|
||||||
_Py_HashRandomization_Init(_PyCoreConfig *core_config)
|
_Py_HashRandomization_Init(_PyCoreConfig *core_config)
|
||||||
{
|
{
|
||||||
char *seed_text;
|
const char *seed_text;
|
||||||
int use_hash_seed = core_config->use_hash_seed;
|
int use_hash_seed = core_config->use_hash_seed;
|
||||||
unsigned long hash_seed = core_config->hash_seed;
|
unsigned long hash_seed = core_config->hash_seed;
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ static int GetRunningOnValgrind(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#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) {
|
if (running_on_valgrind_str) {
|
||||||
return strcmp(running_on_valgrind_str, "0") != 0;
|
return strcmp(running_on_valgrind_str, "0") != 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ Py_FrozenMain(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *p;
|
const char *p;
|
||||||
int i, n, sts = 1;
|
int i, n, sts = 1;
|
||||||
int inspect = 0;
|
int inspect = 0;
|
||||||
int unbuffered = 0;
|
int unbuffered = 0;
|
||||||
|
|
|
@ -168,7 +168,7 @@ Py_SetPath(const wchar_t *path)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Py_SetPythonHome(wchar_t *home)
|
Py_SetPythonHome(const wchar_t *home)
|
||||||
{
|
{
|
||||||
if (home == NULL) {
|
if (home == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -189,7 +189,7 @@ Py_SetPythonHome(wchar_t *home)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Py_SetProgramName(wchar_t *program_name)
|
Py_SetProgramName(const wchar_t *program_name)
|
||||||
{
|
{
|
||||||
if (program_name == NULL || program_name[0] == L'\0') {
|
if (program_name == NULL || program_name[0] == L'\0') {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -414,7 +414,7 @@ static _LocaleCoercionTarget _TARGET_LOCALES[] = {
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *
|
static const char *
|
||||||
get_default_standard_stream_error_handler(void)
|
get_default_standard_stream_error_handler(void)
|
||||||
{
|
{
|
||||||
const char *ctype_loc = setlocale(LC_CTYPE, NULL);
|
const char *ctype_loc = setlocale(LC_CTYPE, NULL);
|
||||||
|
@ -440,7 +440,7 @@ get_default_standard_stream_error_handler(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PY_COERCE_C_LOCALE
|
#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 "
|
"Python detected LC_CTYPE=C: LC_CTYPE coerced to %.20s (set another locale "
|
||||||
"or PYTHONCOERCECLOCALE=0 to disable this locale coercion behavior).\n";
|
"or PYTHONCOERCECLOCALE=0 to disable this locale coercion behavior).\n";
|
||||||
|
|
||||||
|
@ -1757,7 +1757,8 @@ init_sys_streams(void)
|
||||||
PyObject *std = NULL;
|
PyObject *std = NULL;
|
||||||
int fd;
|
int fd;
|
||||||
PyObject * encoding_attr;
|
PyObject * encoding_attr;
|
||||||
char *pythonioencoding = NULL, *encoding, *errors;
|
char *pythonioencoding = NULL;
|
||||||
|
const char *encoding, *errors;
|
||||||
_PyInitError res = _Py_INIT_OK();
|
_PyInitError res = _Py_INIT_OK();
|
||||||
|
|
||||||
/* Hack to avoid a nasty recursion issue when Python is invoked
|
/* 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)
|
sys_breakpointhook(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *keywords)
|
||||||
{
|
{
|
||||||
assert(!PyErr_Occurred());
|
assert(!PyErr_Occurred());
|
||||||
char *envar = Py_GETENV("PYTHONBREAKPOINT");
|
const char *envar = Py_GETENV("PYTHONBREAKPOINT");
|
||||||
|
|
||||||
if (envar == NULL || strlen(envar) == 0) {
|
if (envar == NULL || strlen(envar) == 0) {
|
||||||
envar = "pdb.set_trace";
|
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. */
|
/* The breakpoint is explicitly no-op'd. */
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
char *last_dot = strrchr(envar, '.');
|
const char *last_dot = strrchr(envar, '.');
|
||||||
char *attrname = NULL;
|
const char *attrname = NULL;
|
||||||
PyObject *modulepath = NULL;
|
PyObject *modulepath = NULL;
|
||||||
|
|
||||||
if (last_dot == NULL) {
|
if (last_dot == NULL) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ void
|
||||||
PyThread_init_thread(void)
|
PyThread_init_thread(void)
|
||||||
{
|
{
|
||||||
#ifdef Py_DEBUG
|
#ifdef Py_DEBUG
|
||||||
char *p = Py_GETENV("PYTHONTHREADDEBUG");
|
const char *p = Py_GETENV("PYTHONTHREADDEBUG");
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
if (*p)
|
if (*p)
|
||||||
|
|
Loading…
Reference in New Issue