Author paul.j3
Recipients mhughes, paul.j3, rhettinger, xtreak
Date 2020-07-10.03:01:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I didn't pay attention to the patch that added this "exit_on_error" parameter.  So I don't know exactly what error handling it was supposed to handle or why.  But given the location of the code change, it does not handle every possible error.

Specifically it's  in parser.parse_known_args() where it calls _parse_known_args().  With this parameter True, a argparse.ArgumentError is caught and converted to parse.error() call.  That's the original behavior.

With False, there's no special handling for ArgumentError.  Catching that is left to the developer, as illustrated in the docs.

In the documented example, it's a 'type' error. 'choices' would also behave this way. 'nargs' errors also.  But not all errors are handled like this.

Inside _parse_known_args(), `self.error()` is called several times, once for 'required' arguments failure, and for a required mutually_exclusive_group error.  I count 9 self.error() calls; exit_on_error only changes one of those.

The error highlighted in this issue is called in parser.parse_args().  This calls parse_known_args(), and raises an error if there are 'extras', unrecognized strings.

So clearly the new docs is is describing this new parameter in overly broad terms.  It only changes the handling of a subset of parser.error() calls.  Off hand I can't think of clean way of refining the description without getting overly technical about the error handling.

Developers already had the documented option of changing the parse.error() and parse.exit() methods.
Date User Action Args
2020-07-10 03:01:12paul.j3setrecipients: + paul.j3, rhettinger, xtreak, mhughes
2020-07-10 03:01:12paul.j3setmessageid: <>
2020-07-10 03:01:12paul.j3linkissue41255 messages
2020-07-10 03:01:12paul.j3create