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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy