homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author iritkatriel
Recipients chris.jerdonek, eric.smith, iritkatriel, jeffknupp, paul.j3
Date 2021年12月10日.15:38:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1639150693.27.0.214299319867.issue16977@roundup.psfhosted.org>
In-reply-to
Content
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)
 
 # =======================
History
Date User Action Args
2021年12月10日 15:38:13iritkatrielsetrecipients: + iritkatriel, eric.smith, chris.jerdonek, paul.j3, jeffknupp
2021年12月10日 15:38:13iritkatrielsetmessageid: <1639150693.27.0.214299319867.issue16977@roundup.psfhosted.org>
2021年12月10日 15:38:13iritkatriellinkissue16977 messages
2021年12月10日 15:38:13iritkatrielcreate

AltStyle によって変換されたページ (->オリジナル) /