summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorHarry <harry.lees@gmail.com>2022-08-25 11:18:38 (GMT)
committerGitHub <noreply@github.com>2022-08-25 11:18:38 (GMT)
commitad7340e8c56f61edc1ff4724fe32c9d831db51a7 (patch)
treed33fb0a381f94cb786c2e9491173810c4572a59e /Lib/argparse.py
parentcd492d43a2980faf0ef4a3f99c665023a506414c (diff)
downloadcpython-ad7340e8c56f61edc1ff4724fe32c9d831db51a7.zip
cpython-ad7340e8c56f61edc1ff4724fe32c9d831db51a7.tar.gz
cpython-ad7340e8c56f61edc1ff4724fe32c9d831db51a7.tar.bz2
gh-92445 Improve interaction between nargs="*" and choices() (GH-92565)
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 02e98bb..fe48f86 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -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]: