mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-126946: Improve error message in getopt.do_longs based on existing comment (GH-126871)
Include a list of possibilities for not unique prefix.
This commit is contained in:
parent
733fe59206
commit
f46d847574
3 changed files with 10 additions and 5 deletions
|
@ -185,11 +185,13 @@ def long_has_args(opt, longopts):
|
|||
return True, opt
|
||||
elif opt + '=?' in possibilities:
|
||||
return '?', opt
|
||||
# No exact match, so better be unique.
|
||||
# Possibilities must be unique to be accepted
|
||||
if len(possibilities) > 1:
|
||||
# XXX since possibilities contains all valid continuations, might be
|
||||
# nice to work them into the error msg
|
||||
raise GetoptError(_('option --%s not a unique prefix') % opt, opt)
|
||||
raise GetoptError(
|
||||
_("option --%s not a unique prefix; possible options: %s")
|
||||
% (opt, ", ".join(possibilities)),
|
||||
opt,
|
||||
)
|
||||
assert len(possibilities) == 1
|
||||
unique_match = possibilities[0]
|
||||
if unique_match.endswith('=?'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue