Make the Python CLI error message style more consistent (GH-128129)

This commit is contained in:
9cel 2025-01-11 05:17:35 -04:00 committed by GitHub
parent 553cdc6d68
commit 3a570c6d58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -1012,7 +1012,7 @@ class CmdLineTest(unittest.TestCase):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True)
err_msg = "unknown option --unknown-option\nusage: "
err_msg = "Unknown option: --unknown-option\nusage: "
self.assertTrue(proc.stderr.startswith(err_msg), proc.stderr)
self.assertNotEqual(proc.returncode, 0)

View file

@ -102,7 +102,7 @@ int _PyOS_GetOpt(Py_ssize_t argc, wchar_t * const *argv, int *longindex)
// Parse long option.
if (*opt_ptr == L'\0') {
if (_PyOS_opterr) {
fprintf(stderr, "expected long option\n");
fprintf(stderr, "Expected long option\n");
}
return -1;
}
@ -114,7 +114,7 @@ int _PyOS_GetOpt(Py_ssize_t argc, wchar_t * const *argv, int *longindex)
}
if (!opt->name) {
if (_PyOS_opterr) {
fprintf(stderr, "unknown option %ls\n", argv[_PyOS_optind - 1]);
fprintf(stderr, "Unknown option: %ls\n", argv[_PyOS_optind - 1]);
}
return '_';
}