Message111317
What steps will reproduce the problem?
parser = argparse.ArgumentParser()
parser.add_argument('--foo', nargs=2, metavar=('X','Y','Z'))
parser.parse_args(['-h'])
The error dosn't show up until help is formatted.
Giving any incorrect length of metavar will produce the problem, which
includes a tuple whos length doesn't match a numerical value, more than two metavars to '*' or '+', and more than one metavar to '?'. Furthermore, a tuple of length one causes the error when nargs is greater than 1, '*', or '+'.
What is the expected output? What do you see instead?
When the help is displayed, you get:
TypeError: not all arguments converted during string formatting
Or a similar error message for other cases.
It would be expected that the error message would be more specific. The
error should definitely be raised when add_argument is called, rather than later.
There should be a test that does something like:
for meta in ('X', ('X',), ('X','Y'), ('X','Y','Z')):
for n in (1, 2, 3, '?', '+', '*'):
parser = argparse.ArgumentParser()
parser.add_argument('--foo', nargs=n, metavar=meta)
parser.format_help()
and makes sure that the error shows up in add_argument, not format_help. |
|
Date |
User |
Action |
Args |
2010-07-23 13:34:16 | bethard | set | recipients:
+ bethard |
2010-07-23 13:34:16 | bethard | set | messageid: <1279892056.3.0.745674136702.issue9348@psf.upfronthosting.co.za> |
2010-07-23 13:34:14 | bethard | link | issue9348 messages |
2010-07-23 13:34:14 | bethard | create | |
|