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 <1358303407.58.0.0453921356618.issue16977@psf.upfronthosting.co.za>
In-reply-to
Content
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'])
Namespace(a='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.
History
Date User Action Args
2013-01-16 02:30:07chris.jerdoneksetrecipients: + chris.jerdonek
2013-01-16 02:30:07chris.jerdoneksetmessageid: <1358303407.58.0.0453921356618.issue16977@psf.upfronthosting.co.za>
2013-01-16 02:30:06chris.jerdoneklinkissue16977 messages
2013-01-16 02:30:06chris.jerdonekcreate