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 paul.j3
Recipients BreamoreBoy, Jason.Baker, bethard, eric.araujo, ned.deily, paul.j3
Date 2013-04-17.03:12:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1366168345.85.0.422682278136.issue9849@psf.upfronthosting.co.za>
In-reply-to
Content
It does shift the error from parse_args to add_argument, but the message 'ValueError: length of metavar tuple does not match nargs', indicates that it's a side effect of checking on the tuple form of `metavar`.
http://bugs.python.org/issue9348

There is still room for cleaning up these tests.  There are 2 functions that define what are acceptable values for nargs, [None, OPTIONAL, ZERO_OR_MORE, ONE_OR_MORE, REMAINDER, PARSER, integer].  Should one or other explicitly check nargs is an integer if it does not match one of the other strings?

And the test in _ActionContainer.add_argument()

    # raise an error if the metavar does not match the type
    if hasattr(self, "_get_formatter"):
        try:
            self._get_formatter()._format_args(action, None)
        except TypeError:
            raise ValueError("length of metavar tuple does not match nargs")

uses an ArgumentParser._get_formatter method  (though 'hasattr' prevents runtime errors).  In fact both functions that use nargs belong to the parser, not the container.  I wonder if `add_argument` should be moved to ArgumentParser.
History
Date User Action Args
2013-04-17 03:12:25paul.j3setrecipients: + paul.j3, bethard, ned.deily, eric.araujo, Jason.Baker, BreamoreBoy
2013-04-17 03:12:25paul.j3setmessageid: <1366168345.85.0.422682278136.issue9849@psf.upfronthosting.co.za>
2013-04-17 03:12:25paul.j3linkissue9849 messages
2013-04-17 03:12:25paul.j3create