Issue 67 in argparse: Calling add_argument with the wrong number of metavars causes delayed error message.

2 views
Skip to first unread message

argp...@googlecode.com

unread,
Mar 13, 2010, 10:52:00 PM3/13/10
to argpar...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

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

argp...@googlecode.com

unread,
Mar 13, 2010, 11:14:31 PM3/13/10
to argpar...@googlegroups.com

Comment #1 on 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

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

argp...@googlecode.com

unread,
Jul 23, 2010, 9:35:13 AM7/23/10
to argpar...@googlegroups.com
Updates:
Status: Duplicate

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

Reply all
Reply to author
Forward
0 new messages