Skip to content

Commit 362cccb

Browse files
committed
gh-145092: fix discards const qualifier from pointer
Since glibc-2.43 and ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return pointers into their input arrays now have definitions as macros that return a pointer to a const-qualified type when the input argument is a pointer to a const-qualified type. wchar_t * pointer returns are only being used for comparisons so declare then as const, which matches the input variables.
1 parent 2be2dd5 commit 362cccb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Python/preconfig.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ _Py_get_xoption(const PyWideStringList *xoptions, const wchar_t *name)
584584
for (Py_ssize_t i=0; i < xoptions->length; i++) {
585585
const wchar_t *option = xoptions->items[i];
586586
size_t len;
587-
wchar_t *sep = wcschr(option, L'=');
587+
const wchar_t *sep = wcschr(option, L'=');
588588
if (sep != NULL) {
589589
len = (sep - option);
590590
}
@@ -615,7 +615,7 @@ preconfig_init_utf8_mode(PyPreConfig *config, const _PyPreCmdline *cmdline)
615615
const wchar_t *xopt;
616616
xopt = _Py_get_xoption(&cmdline->xoptions, L"utf8");
617617
if (xopt) {
618-
wchar_t *sep = wcschr(xopt, L'=');
618+
const wchar_t *sep = wcschr(xopt, L'=');
619619
if (sep) {
620620
xopt = sep + 1;
621621
if (wcscmp(xopt, L"1") == 0) {

0 commit comments

Comments
 (0)