Fix _PyOS_GetOpt() error message for non-ASCII characters (#158626)

Replace %c with %lc.
This commit is contained in:
Victor Stinner authored and GitHub committed 2026-10-03 15:37:58 +02:00
1 parent f5e913c7f7
commit b42fdf6b44
2 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -684,7 +684,7 @@ class CmdLineTest(unittest.TestCase):
@support.cpython_only
def test_unknown_options(self):
# Test unknown option -a
# Test unknown option
for option in ('-z', '--long-option', '---'):
with self.subTest(option=option):
rc, out, err = assert_python_failure('-E', option)
+2 -2
View File
@@ -160,7 +160,7 @@ _PyOS_GetOpt(struct _PyOS_GetOpt *getopt)
wchar_t *ptr = wcschr(SHORT_OPTS, option);
if (ptr == NULL) {
if (error) {
fprintf(stderr, "Unknown option: -%c\n", (char)option);
fprintf(stderr, "Unknown option: -%lc\n", option);
}
return '_';
}
@@ -174,7 +174,7 @@ _PyOS_GetOpt(struct _PyOS_GetOpt *getopt)
if (getopt->index >= argc) {
if (error) {
fprintf(stderr,
"Argument expected for the -%c option\n", (char)option);
"Argument expected for the -%lc option\n", option);
}
return '_';
}