https://github.com/python/cpython/commit/8d32ae75d45ff0c9fd848b78a95bbec882d7ca3a
commit: 8d32ae75d45ff0c9fd848b78a95bbec882d7ca3a
branch: 3.15
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-05-15T11:36:21Z
summary:
[3.15] gh-149707: Fix compiler warning in _ctypes_test on strchr() (#149791)
(#149865)
gh-149707: Fix compiler warning in _ctypes_test on strchr() (#149791)
Change my_strchr() return type to "const char*" (add "const").
Fix the compiler warning:
Modules/_ctypes/_ctypes_test.c: In function 'my_strchr':
Modules/_ctypes/_ctypes_test.c:451:12: warning: return discards
'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
451 | return strchr(s, c);
| ^~~~~~
When using C23, strchr(text, ch) return type is "const char*" if text
type is "const char*".
(cherry picked from commit 5465b69255890650df99debb8256e0a7bc68138b)
files:
M Modules/_ctypes/_ctypes_test.c
diff --git a/Modules/_ctypes/_ctypes_test.c b/Modules/_ctypes/_ctypes_test.c
index a0c9d8b70fee46..991ff0d675c2f1 100644
--- a/Modules/_ctypes/_ctypes_test.c
+++ b/Modules/_ctypes/_ctypes_test.c
@@ -446,7 +446,7 @@ EXPORT(char *)my_strtok(char *token, const char *delim)
return strtok(token, delim);
}
-EXPORT(char *)my_strchr(const char *s, int c)
+EXPORT(const char *) my_strchr(const char *s, int c)
{
return strchr(s, c);
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]