Skip to content

Commit b2376f9

Browse files
Fix compiler warnings in init_dump_ascii_wstr() (GH-22150)
Fix GCC 9.3 (using -O3) warnings on x86: initconfig.c: In function ‘init_dump_ascii_wstr’: initconfig.c:2679:34: warning: format ‘%lc’ expects argument of type ‘wint_t’, but argument 2 has type ‘wchar_t’ {aka ‘long int’} 2679 | PySys_WriteStderr("%lc", ch); initconfig.c:2682:38: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘wchar_t’ {aka ‘long int’} 2682 | PySys_WriteStderr("\\x%02x", ch); initconfig.c:2686:38: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘wchar_t’ {aka ‘long int’} 2686 | PySys_WriteStderr("\\U%08x", ch); initconfig.c:2690:38: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘wchar_t’ {aka ‘long int’} 2690 | PySys_WriteStderr("\\u%04x", ch); (cherry picked from commit 640e8e1) Co-authored-by: Victor Stinner <[email protected]>
1 parent 11a82c7 commit b2376f9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Python/initconfig.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2672,7 +2672,7 @@ init_dump_ascii_wstr(const wchar_t *str)
26722672

26732673
PySys_WriteStderr("'");
26742674
for (; *str != L'\0'; str++) {
2675-
wchar_t ch = *str;
2675+
unsigned int ch = (unsigned int)*str;
26762676
if (ch == L'\'') {
26772677
PySys_WriteStderr("\\'");
26782678
} else if (0x20 <= ch && ch < 0x7f) {

0 commit comments

Comments
 (0)