New issue 67 by l...@gis.net: Calling add_argument with the wrong number of
metavars causes delayed error message.
http://code.google.com/p/argparse/issues/detail?id=67
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.
What version of the product are you using? On what operating system?
argparse 1.0 on Debian Linux
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
Here's a little example that uses a bunch of variations to trigger the bug.
It could
be the basis of some sort of test.
Attachments:
multi.py 427 bytes
Comment #2 on issue 67 by steven.bethard: Calling add_argument with the
wrong number of metavars causes delayed error message.
http://code.google.com/p/argparse/issues/detail?id=67
Moved to http://bugs.python.org/issue9348