summaryrefslogtreecommitdiff
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-01-20 15:13:17 -0800
committerGitHub <noreply@github.com>2022-01-20 15:13:17 -0800
commite5edc8d737a45d9d8b9b93b8be52f85d79d0f417 (patch)
tree8448950dc9ab2057fdd805e4f821d9ea09104030 /Lib/argparse.py
parent876ade1ae3a805b546a211fd7303253c10395569 (diff)
downloadcpython-git-e5edc8d737a45d9d8b9b93b8be52f85d79d0f417.tar.gz
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 9e87c0e03fa501fb90008547983ce4c1dcaaf90c) Co-authored-by: Felix Fontein <felix@fontein.de>
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index e177e4fe03..b71a6703c3 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -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__(