[issue9348] Calling argparse's add_argument with the wrong number of metavars causes delayed error message

Denver Coneybeare report at bugs.python.org
Sat Mar 19 20:08:59 CET 2011


Denver Coneybeare <denver.coneybeare at gmail.com> added the comment:

For kicks, I just took a look at this old, forgotten issue.  I agree with the submitter that add_argument() should fail if nargs and metavar do not match, instead of having format_help() raise the exception later on.

I've attached a patch (issue9348_patch_v01.txt) with a proposed fix and associated test cases.  The drawback of my approach is that if a custom HelpFormatter is used which has different semantics for metavar it could cause add_argument() to incorrectly reject the metavar value.  I'm not sure how common that is though.

----------
nosy: +denversc
Added file: http://bugs.python.org/file21294/issue9348_patch_v01.txt

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9348>
_______________________________________


More information about the Python-bugs-list mailing list