paul j3 added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21666>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to