Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4ae06c53
Commit
4ae06c53
authored
Dec 12, 2017
by
Serhiy Storchaka
Committed by
GitHub
Dec 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-32241: Add the const qualifire to declarations of umodifiable strings. (#4748)
parent
5ce0a2a1
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
59 additions
and
56 deletions
+59
-56
Doc/c-api/init.rst
Doc/c-api/init.rst
+2
-2
Include/pylifecycle.h
Include/pylifecycle.h
+2
-2
Misc/NEWS.d/next/C API/2017-12-07-15-58-15.bpo-32241.LbyQt6.rst
...EWS.d/next/C API/2017-12-07-15-58-15.bpo-32241.LbyQt6.rst
+2
-0
Modules/getaddrinfo.c
Modules/getaddrinfo.c
+1
-1
Modules/getpath.c
Modules/getpath.c
+1
-1
Modules/main.c
Modules/main.c
+23
-23
Objects/obmalloc.c
Objects/obmalloc.c
+1
-1
PC/getpathp.c
PC/getpathp.c
+11
-11
Python/bootstrap_hash.c
Python/bootstrap_hash.c
+4
-4
Python/dynamic_annotations.c
Python/dynamic_annotations.c
+1
-1
Python/frozenmain.c
Python/frozenmain.c
+1
-1
Python/pathconfig.c
Python/pathconfig.c
+2
-2
Python/pylifecycle.c
Python/pylifecycle.c
+4
-3
Python/sysmodule.c
Python/sysmodule.c
+3
-3
Python/thread.c
Python/thread.c
+1
-1
No files found.
Doc/c-api/init.rst
View file @
4ae06c53
...
...
@@ -338,7 +338,7 @@ Process-wide parameters
.. versionadded:: 3.4
.. c:function:: void Py_SetProgramName(wchar_t *name)
.. c:function:: void Py_SetProgramName(
const
wchar_t *name)
.. index::
single: Py_Initialize()
...
...
@@ -605,7 +605,7 @@ Process-wide parameters
.. 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
Python libraries. See :envvar:`PYTHONHOME` for the meaning of the
...
...
Include/pylifecycle.h
View file @
4ae06c53
...
...
@@ -37,10 +37,10 @@ typedef struct {
#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
(
void
)
Py_SetPythonHome
(
wchar_t
*
);
PyAPI_FUNC
(
void
)
Py_SetPythonHome
(
const
wchar_t
*
);
PyAPI_FUNC
(
wchar_t
*
)
Py_GetPythonHome
(
void
);
#ifndef Py_LIMITED_API
...
...
Misc/NEWS.d/next/C API/2017-12-07-15-58-15.bpo-32241.LbyQt6.rst
0 → 100644
View file @
4ae06c53
:c:func:`Py_SetProgramName` and :c:func:`Py_SetPythonHome` now take the
``const wchar *`` arguments instead of ``wchar *``.
Modules/getaddrinfo.c
View file @
4ae06c53
...
...
@@ -251,7 +251,7 @@ getaddrinfo(const char*hostname, const char*servname,
if
(
firsttime
)
{
/* translator hack */
{
char
*
q
=
getenv
(
"GAI"
);
c
onst
c
har
*
q
=
getenv
(
"GAI"
);
if
(
q
&&
inet_pton
(
AF_INET6
,
q
,
&
faith_prefix
)
==
1
)
translate
=
YES
;
}
...
...
Modules/getpath.c
View file @
4ae06c53
...
...
@@ -910,7 +910,7 @@ calculate_init(PyCalculatePath *calculate,
const
_PyMainInterpreterConfig
*
main_config
)
{
size_t
len
;
char
*
path
=
getenv
(
"PATH"
);
c
onst
c
har
*
path
=
getenv
(
"PATH"
);
if
(
path
)
{
calculate
->
path_env
=
Py_DecodeLocale
(
path
,
&
len
);
if
(
!
calculate
->
path_env
)
{
...
...
Modules/main.c
View file @
4ae06c53
...
...
@@ -154,10 +154,10 @@ pymain_usage(int error, const wchar_t* program)
}
static
char
*
static
c
onst
c
har
*
pymain_get_env_var
(
const
char
*
name
)
{
char
*
var
=
Py_GETENV
(
name
);
c
onst
c
har
*
var
=
Py_GETENV
(
name
);
if
(
var
&&
var
[
0
]
!=
'\0'
)
{
return
var
;
}
...
...
@@ -170,7 +170,7 @@ pymain_get_env_var(const char *name)
static
void
pymain_run_startup
(
PyCompilerFlags
*
cf
)
{
char
*
startup
=
pymain_get_env_var
(
"PYTHONSTARTUP"
);
c
onst
c
har
*
startup
=
pymain_get_env_var
(
"PYTHONSTARTUP"
);
if
(
startup
==
NULL
)
{
return
;
}
...
...
@@ -542,7 +542,7 @@ error:
static
wchar_t
*
pymain_wstrdup
(
_PyMain
*
pymain
,
wchar_t
*
str
)
pymain_wstrdup
(
_PyMain
*
pymain
,
const
wchar_t
*
str
)
{
wchar_t
*
str2
=
_PyMem_RawWcsdup
(
str
);
if
(
str2
==
NULL
)
{
...
...
@@ -554,7 +554,7 @@ pymain_wstrdup(_PyMain *pymain, wchar_t *str)
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
);
if
(
str2
==
NULL
)
{
...
...
@@ -802,7 +802,7 @@ pymain_warnings_envvar(_PyMain *pymain)
}
#ifdef MS_WINDOWS
wchar_t
*
wp
;
const
wchar_t
*
wp
;
if
((
wp
=
_wgetenv
(
L"PYTHONWARNINGS"
))
&&
*
wp
!=
L'\0'
)
{
wchar_t
*
warning
,
*
context
=
NULL
;
...
...
@@ -824,7 +824,7 @@ pymain_warnings_envvar(_PyMain *pymain)
PyMem_RawFree
(
buf
);
}
#else
char
*
p
=
pymain_get_env_var
(
"PYTHONWARNINGS"
);
c
onst
c
har
*
p
=
pymain_get_env_var
(
"PYTHONWARNINGS"
);
if
(
p
!=
NULL
)
{
char
*
buf
,
*
oldloc
;
...
...
@@ -909,7 +909,7 @@ config_get_program_name(_PyMainInterpreterConfig *config)
assert
(
config
->
program_name
==
NULL
);
/* 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
)
{
config
->
program_name
=
_PyMem_RawWcsdup
(
program_name
);
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.
See Lib/plat-mac/bundlebuiler.py for details about the bootstrap
script. */
char
*
p
=
pymain_get_env_var
(
"PYTHONEXECUTABLE"
);
c
onst
c
har
*
p
=
pymain_get_env_var
(
"PYTHONEXECUTABLE"
);
if
(
p
!=
NULL
)
{
size_t
len
;
wchar_t
*
program_name
=
Py_DecodeLocale
(
p
,
&
len
);
...
...
@@ -939,7 +939,7 @@ config_get_program_name(_PyMainInterpreterConfig *config)
}
#ifdef WITH_NEXT_FRAMEWORK
else
{
char
*
pyvenv_launcher
=
getenv
(
"__PYVENV_LAUNCHER__"
);
c
onst
c
har
*
pyvenv_launcher
=
getenv
(
"__PYVENV_LAUNCHER__"
);
if
(
pyvenv_launcher
&&
*
pyvenv_launcher
)
{
/* Used by Mac/Tools/pythonw.c to forward
* 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
)
{
_Py_OptList
*
list
=
&
pymain
->
cmdline
.
xoptions
;
...
...
@@ -1312,11 +1312,11 @@ pymain_get_xoption(_PyMain *pymain, wchar_t *name)
static
int
pymain_str_to_int
(
char
*
str
,
int
*
result
)
pymain_str_to_int
(
c
onst
c
har
*
str
,
int
*
result
)
{
errno
=
0
;
char
*
endptr
=
str
;
long
value
=
strtol
(
str
,
&
endptr
,
10
);
c
onst
c
har
*
endptr
=
str
;
long
value
=
strtol
(
str
,
(
char
**
)
&
endptr
,
10
);
if
(
*
endptr
!=
'\0'
||
errno
==
ERANGE
)
{
return
-
1
;
}
...
...
@@ -1330,11 +1330,11 @@ pymain_str_to_int(char *str, int *result)
static
int
pymain_wstr_to_int
(
wchar_t
*
wstr
,
int
*
result
)
pymain_wstr_to_int
(
const
wchar_t
*
wstr
,
int
*
result
)
{
errno
=
0
;
wchar_t
*
endptr
=
wstr
;
long
value
=
wcstol
(
wstr
,
&
endptr
,
10
);
const
wchar_t
*
endptr
=
wstr
;
long
value
=
wcstol
(
wstr
,
(
wchar_t
**
)
&
endptr
,
10
);
if
(
*
endptr
!=
'\0'
||
errno
==
ERANGE
)
{
return
-
1
;
}
...
...
@@ -1353,7 +1353,7 @@ pymain_init_tracemalloc(_PyMain *pymain)
int
nframe
;
int
valid
;
char
*
env
=
pymain_get_env_var
(
"PYTHONTRACEMALLOC"
);
c
onst
c
har
*
env
=
pymain_get_env_var
(
"PYTHONTRACEMALLOC"
);
if
(
env
)
{
if
(
!
pymain_str_to_int
(
env
,
&
nframe
))
{
valid
=
(
nframe
>=
1
);
...
...
@@ -1369,9 +1369,9 @@ pymain_init_tracemalloc(_PyMain *pymain)
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
)
{
wchar_t
*
sep
=
wcschr
(
xoption
,
L'='
);
const
wchar_t
*
sep
=
wcschr
(
xoption
,
L'='
);
if
(
sep
)
{
if
(
!
pymain_wstr_to_int
(
sep
+
1
,
&
nframe
))
{
valid
=
(
nframe
>=
1
);
...
...
@@ -1398,7 +1398,7 @@ pymain_init_tracemalloc(_PyMain *pymain)
static
void
pymain_set_flag_from_env
(
int
*
flag
,
const
char
*
name
)
{
char
*
var
=
pymain_get_env_var
(
name
);
c
onst
c
har
*
var
=
pymain_get_env_var
(
name
);
if
(
!
var
)
{
return
;
}
...
...
@@ -1449,7 +1449,7 @@ config_get_env_var_dup(wchar_t **dest, wchar_t *wname, char *name)
}
#ifdef MS_WINDOWS
wchar_t
*
var
=
_wgetenv
(
wname
);
const
wchar_t
*
var
=
_wgetenv
(
wname
);
if
(
!
var
||
var
[
0
]
==
'\0'
)
{
*
dest
=
NULL
;
return
0
;
...
...
@@ -1462,7 +1462,7 @@ config_get_env_var_dup(wchar_t **dest, wchar_t *wname, char *name)
*
dest
=
copy
;
#else
char
*
var
=
getenv
(
name
);
c
onst
c
har
*
var
=
getenv
(
name
);
if
(
!
var
||
var
[
0
]
==
'\0'
)
{
*
dest
=
NULL
;
return
0
;
...
...
Objects/obmalloc.c
View file @
4ae06c53
...
...
@@ -1167,7 +1167,7 @@ new_arena(void)
static
int
debug_stats
=
-
1
;
if
(
debug_stats
==
-
1
)
{
char
*
opt
=
Py_GETENV
(
"PYTHONMALLOCSTATS"
);
c
onst
c
har
*
opt
=
Py_GETENV
(
"PYTHONMALLOCSTATS"
);
debug_stats
=
(
opt
!=
NULL
&&
*
opt
!=
'\0'
);
}
if
(
debug_stats
)
...
...
PC/getpathp.c
View file @
4ae06c53
...
...
@@ -118,8 +118,8 @@
#endif
typedef
struct
{
wchar_t
*
path_env
;
/* PATH environment variable */
wchar_t
*
home
;
/* PYTHONHOME environment variable */
const
wchar_t
*
path_env
;
/* PATH environment variable */
const
wchar_t
*
home
;
/* PYTHONHOME environment variable */
/* Registry key "Software\Python\PythonCore\PythonPath" */
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
exists
(
wchar_t
*
filename
)
exists
(
const
wchar_t
*
filename
)
{
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.
assumption provided by only caller, calculate_path_impl() */
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 */
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
);
}
else
if
(
calculate
->
path_env
)
{
wchar_t
*
path
=
calculate
->
path_env
;
const
wchar_t
*
path
=
calculate
->
path_env
;
while
(
1
)
{
wchar_t
*
delim
=
wcschr
(
path
,
DELIM
);
const
wchar_t
*
delim
=
wcschr
(
path
,
DELIM
);
if
(
delim
)
{
size_t
len
=
delim
-
path
;
...
...
@@ -845,7 +845,7 @@ calculate_module_search_path(const _PyMainInterpreterConfig *main_config,
/* Calculate size of return buffer */
size_t
bufsz
=
0
;
if
(
calculate
->
home
!=
NULL
)
{
wchar_t
*
p
;
const
wchar_t
*
p
;
bufsz
=
1
;
for
(
p
=
PYTHONPATH
;
*
p
;
p
++
)
{
if
(
*
p
==
DELIM
)
{
...
...
@@ -922,8 +922,8 @@ calculate_module_search_path(const _PyMainInterpreterConfig *main_config,
*
buf
++
=
DELIM
;
}
}
else
{
wchar_t
*
p
=
PYTHONPATH
;
wchar_t
*
q
;
const
wchar_t
*
p
=
PYTHONPATH
;
const
wchar_t
*
q
;
size_t
n
;
for
(;;)
{
q
=
wcschr
(
p
,
DELIM
);
...
...
@@ -967,10 +967,10 @@ calculate_module_search_path(const _PyMainInterpreterConfig *main_config,
*/
if
(
prefix
[
0
]
==
L'\0'
)
{
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
)
{
Py_ssize_t
nchars
;
wchar_t
*
lookEnd
=
look
;
const
wchar_t
*
lookEnd
=
look
;
/* 'look' will end up one character before the
start of the path in question - even if this
is one character before the start of the buffer
...
...
Python/bootstrap_hash.c
View file @
4ae06c53
...
...
@@ -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
(
c
onst
c
har
*
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
;
c
onst
c
har
*
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
;
c
onst
c
har
*
seed_text
;
int
use_hash_seed
=
core_config
->
use_hash_seed
;
unsigned
long
hash_seed
=
core_config
->
hash_seed
;
...
...
Python/dynamic_annotations.c
View file @
4ae06c53
...
...
@@ -120,7 +120,7 @@ static int GetRunningOnValgrind(void) {
#endif
#ifndef _MSC_VER
char
*
running_on_valgrind_str
=
getenv
(
"RUNNING_ON_VALGRIND"
);
c
onst
c
har
*
running_on_valgrind_str
=
getenv
(
"RUNNING_ON_VALGRIND"
);
if
(
running_on_valgrind_str
)
{
return
strcmp
(
running_on_valgrind_str
,
"0"
)
!=
0
;
}
...
...
Python/frozenmain.c
View file @
4ae06c53
...
...
@@ -23,7 +23,7 @@ Py_FrozenMain(int argc, char **argv)
exit
(
1
);
}
char
*
p
;
c
onst
c
har
*
p
;
int
i
,
n
,
sts
=
1
;
int
inspect
=
0
;
int
unbuffered
=
0
;
...
...
Python/pathconfig.c
View file @
4ae06c53
...
...
@@ -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
;
...
...
Python/pylifecycle.c
View file @
4ae06c53
...
...
@@ -414,7 +414,7 @@ static _LocaleCoercionTarget _TARGET_LOCALES[] = {
{
NULL
}
};
static
char
*
static
c
onst
c
har
*
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
...
...
Python/sysmodule.c
View file @
4ae06c53
...
...
@@ -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"
);
c
onst
c
har
*
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
;
c
onst
c
har
*
last_dot
=
strrchr
(
envar
,
'.'
);
c
onst
c
har
*
attrname
=
NULL
;
PyObject
*
modulepath
=
NULL
;
if
(
last_dot
==
NULL
)
{
...
...
Python/thread.c
View file @
4ae06c53
...
...
@@ -61,7 +61,7 @@ void
PyThread_init_thread
(
void
)
{
#ifdef Py_DEBUG
char
*
p
=
Py_GETENV
(
"PYTHONTHREADDEBUG"
);
c
onst
c
har
*
p
=
Py_GETENV
(
"PYTHONTHREADDEBUG"
);
if
(
p
)
{
if
(
*
p
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment