]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix compiler warnings in init_dump_ascii_wstr() (GH-22150)
authorVictor Stinner <vstinner@python.org>
Wed, 9 Sep 2020 10:07:17 +0000 (12:07 +0200)
committerGitHub <noreply@github.com>
Wed, 9 Sep 2020 10:07:17 +0000 (12:07 +0200)
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);

Python/initconfig.c

index 38d64b63afcc9c1b47372aeae2256c78a08b8bc2..880e145ec031cd10ac2b2a03a44fb7ef765db21b 100644 (file)
@@ -2670,7 +2670,7 @@ init_dump_ascii_wstr(const wchar_t *str)
 
     PySys_WriteStderr("'");
     for (; *str != L'\0'; str++) {
-        wchar_t ch = *str;
+        unsigned int ch = (unsigned int)*str;
         if (ch == L'\'') {
             PySys_WriteStderr("\\'");
         } else if (0x20 <= ch && ch < 0x7f) {