Author paul.j3
Recipients paul.j3, v+python
Date 2014-06-08.06:03:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1402207385.07.0.69337588641.issue21666@psf.upfronthosting.co.za>
In-reply-to
Content
In http://bugs.python.org/file30010/nargswarn.patch adding the '_expand_help(action)' line should test the help string (during add_argument).

    def _check_argument(self, action):
        # check action arguments
        # focus on the arguments that the parent container does not know about
        # check nargs and metavar tuple
        try:
            self._get_formatter()._format_args(action, None)
        except ValueError as e:
            raise ArgumentError(action, str(e))
        except TypeError:
            #raise ValueError("length of metavar tuple does not match nargs")
            raise ArgumentError(action, "length of metavar tuple does not match nargs")
        # check the 'help' string
        try:
            self._get_formatter()._expand_help(action)
        except (ValueError, TypeError, KeyError) as e:
            raise ArgumentError(action, 'badly formed help string')

The 'except' clause may need to be changed to capture all (or just most?) of the possible errors in the format string.  Besides your error I can imagine '%(error)s` (a KeyError).  We also need to pay attention to the differences between Py2 and Py3 errors.
History
Date User Action Args
2014-06-08 06:03:05paul.j3setrecipients: + paul.j3, v+python
2014-06-08 06:03:05paul.j3setmessageid: <1402207385.07.0.69337588641.issue21666@psf.upfronthosting.co.za>
2014-06-08 06:03:05paul.j3linkissue21666 messages
2014-06-08 06:03:04paul.j3create