https://github.com/python/cpython/commit/3a570c6d58bd5ad7d7c13b24dafccc2701081d9f
commit: 3a570c6d58bd5ad7d7c13b24dafccc2701081d9f
branch: main
author: 9cel <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2025-01-11T11:17:35+02:00
summary:
Make the Python CLI error message style more consistent (GH-128129)
files:
M Lib/test/test_cmd_line.py
M Python/getopt.c
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index 634efda354407f..dfdbb80b94d66f 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -1012,7 +1012,7 @@ def test_parsing_error(self):
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)
diff --git a/Python/getopt.c b/Python/getopt.c
index f64c89fa22734a..39a6938dec7663 100644
--- a/Python/getopt.c
+++ b/Python/getopt.c
@@ -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 '_';
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]