bpo-46080: fix argparse help generation exception in edge case (GH-30111)

Fix an uncaught exception during help text generation when
argparse.BooleanOptionalAction is used with default=argparse.SUPPRESS
and help is specified.
This commit is contained in:
Felix Fontein 2022-01-20 23:48:48 +01:00 committed by GitHub
parent 30fb6d073d
commit 9e87c0e03f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View file

@ -881,7 +881,7 @@ class BooleanOptionalAction(Action):
option_string = '--no-' + option_string[2:]
_option_strings.append(option_string)
if help is not None and default is not None:
if help is not None and default is not None and default is not SUPPRESS:
help += " (default: %(default)s)"
super().__init__(