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 py.user
Recipients py.user
Date 2015-06-12.21:41:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1434145271.17.0.0249492593034.issue24441@psf.upfronthosting.co.za>
In-reply-to
Content
A script, configuring argparse to have no choices:

#!/usr/bin/env python3

import argparse

parser = argparse.ArgumentParser()
parser.add_argument('foo', choices=[])

args = parser.parse_args()
print(args)


Running it:

[guest@localhost args]$ ./t.py
usage: t.py [-h] {}
t.py: error: too few arguments
[guest@localhost args]$ ./t.py a
usage: t.py [-h] {}
t.py: error: argument foo: invalid choice: 'a' (choose from )
[guest@localhost args]$ ./t.py ""
usage: t.py [-h] {}
t.py: error: argument foo: invalid choice: '' (choose from )
[guest@localhost args]$

[guest@localhost args]$ ./t.py -h
usage: t.py [-h] {}

positional arguments:
  {}

optional arguments:
  -h, --help  show this help message and exit
[guest@localhost args]$


ISTM, it should throw an exception about empty choices rather than show help with empty choices.
History
Date User Action Args
2015-06-12 21:41:11py.usersetrecipients: + py.user
2015-06-12 21:41:11py.usersetmessageid: <1434145271.17.0.0249492593034.issue24441@psf.upfronthosting.co.za>
2015-06-12 21:41:11py.userlinkissue24441 messages
2015-06-12 21:41:10py.usercreate