Skip to content

Commit 1115718

Browse files
9celpull[bot]
authored andcommitted
Make the Python CLI error message style more consistent (GH-128129)
1 parent b1f39f8 commit 1115718

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Lib/test/test_cmd_line.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ def test_parsing_error(self):
10121012
stdout=subprocess.PIPE,
10131013
stderr=subprocess.PIPE,
10141014
text=True)
1015-
err_msg = "unknown option --unknown-option\nusage: "
1015+
err_msg = "Unknown option: --unknown-option\nusage: "
10161016
self.assertTrue(proc.stderr.startswith(err_msg), proc.stderr)
10171017
self.assertNotEqual(proc.returncode, 0)
10181018

Python/getopt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ int _PyOS_GetOpt(Py_ssize_t argc, wchar_t * const *argv, int *longindex)
102102
// Parse long option.
103103
if (*opt_ptr == L'\0') {
104104
if (_PyOS_opterr) {
105-
fprintf(stderr, "expected long option\n");
105+
fprintf(stderr, "Expected long option\n");
106106
}
107107
return -1;
108108
}
@@ -114,7 +114,7 @@ int _PyOS_GetOpt(Py_ssize_t argc, wchar_t * const *argv, int *longindex)
114114
}
115115
if (!opt->name) {
116116
if (_PyOS_opterr) {
117-
fprintf(stderr, "unknown option %ls\n", argv[_PyOS_optind - 1]);
117+
fprintf(stderr, "Unknown option: %ls\n", argv[_PyOS_optind - 1]);
118118
}
119119
return '_';
120120
}

0 commit comments

Comments
 (0)