mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
(cherry picked from commit 9e87c0e03f
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
e8e71c481a
commit
c6691a7ccb
3 changed files with 9 additions and 3 deletions
|
@ -878,7 +878,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__(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue