Skip to content

Commit b42fdf6

Browse files
authored
Fix _PyOS_GetOpt() error message for non-ASCII characters (#158626)
Replace %c with %lc.
1 parent f5e913c commit b42fdf6

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎Lib/test/test_cmd_line.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ def test_del___main__(self):
684684

685685
@support.cpython_only
686686
def test_unknown_options(self):
687-
# Test unknown option -a
687+
# Test unknown option
688688
for option in ('-z', '--long-option', '---'):
689689
with self.subTest(option=option):
690690
rc, out, err = assert_python_failure('-E', option)

‎Python/getopt.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ _PyOS_GetOpt(struct _PyOS_GetOpt *getopt)
160160
wchar_t *ptr = wcschr(SHORT_OPTS, option);
161161
if (ptr == NULL) {
162162
if (error) {
163-
fprintf(stderr, "Unknown option: -%c\n", (char)option);
163+
fprintf(stderr, "Unknown option: -%lc\n", option);
164164
}
165165
return '_';
166166
}
@@ -174,7 +174,7 @@ _PyOS_GetOpt(struct _PyOS_GetOpt *getopt)
174174
if (getopt->index >= argc) {
175175
if (error) {
176176
fprintf(stderr,
177-
"Argument expected for the -%c option\n", (char)option);
177+
"Argument expected for the -%lc option\n", option);
178178
}
179179
return '_';
180180
}

0 commit comments

Comments
 (0)