mirror of
https://github.com/python/cpython.git
synced 2025-08-26 19:55:24 +00:00
gh-92445 Improve interaction between nargs="*" and choices() (GH-92565)
This commit is contained in:
parent
cd492d43a2
commit
ad7340e8c5
3 changed files with 13 additions and 1 deletions
|
@ -2477,9 +2477,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||
not action.option_strings):
|
||||
if action.default is not None:
|
||||
value = action.default
|
||||
self._check_value(action, value)
|
||||
else:
|
||||
# since arg_strings is always [] at this point
|
||||
# there is no need to use self._check_value(action, value)
|
||||
value = arg_strings
|
||||
self._check_value(action, value)
|
||||
|
||||
# single argument or optional argument produces a single value
|
||||
elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue