Message408213
We could make the error message less wrong:
>>> p.parse_args(['d'])
usage: [-h] {a,b,c}
: error: argument a: invalid choice: 'd' (choose a value in 'abc')
% git diff
diff --git a/Lib/argparse.py b/Lib/argparse.py
index b44fa4f0f6..f03cc1f110 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -2499,8 +2499,8 @@ def _check_value(self, action, value):
# converted value must be one of the choices (if specified)
if action.choices is not None and value not in action.choices:
args = {'value': value,
- 'choices': ', '.join(map(repr, action.choices))}
- msg = _('invalid choice: %(value)r (choose from %(choices)s)')
+ 'choices': repr(action.choices)}
+ msg = _('invalid choice: %(value)r (choose a value in %(choices)s)')
raise ArgumentError(action, msg % args)
# ======================= |
|
Date |
User |
Action |
Args |
2021-12-10 15:38:13 | iritkatriel | set | recipients:
+ iritkatriel, eric.smith, chris.jerdonek, paul.j3, jeffknupp |
2021-12-10 15:38:13 | iritkatriel | set | messageid: <1639150693.27.0.214299319867.issue16977@roundup.psfhosted.org> |
2021-12-10 15:38:13 | iritkatriel | link | issue16977 messages |
2021-12-10 15:38:13 | iritkatriel | create | |
|