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 chris.jerdonek
Recipients chris.jerdonek
Date 2013-01-16.02:30:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
When passing a string for the choices argument, argparse's usage and error messages differ from its behavior:

>>> p = argparse.ArgumentParser()
>>> p.add_argument('a', choices='abc')
>>> p.parse_args(['d'])
usage: [-h] {a,b,c}
: error: argument a: invalid choice: 'd' (choose from 'a', 'b', 'c')
>>> p.parse_args(['bc'])

This is because argparse uses the "in" operator instead of sequence iteration to check whether an argument value is valid.  Any resolution should also consider the behavior for string subclasses as well as perhaps bytes-like objects.
Date User Action Args
2013-01-16 02:30:07chris.jerdoneksetrecipients: + chris.jerdonek
2013-01-16 02:30:07chris.jerdoneksetmessageid: <>
2013-01-16 02:30:06chris.jerdoneklinkissue16977 messages
2013-01-16 02:30:06chris.jerdonekcreate