mirror of
https://github.com/python/cpython.git
synced 2025-10-08 08:01:55 +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.
This commit is contained in:
parent
30fb6d073d
commit
9e87c0e03f
3 changed files with 9 additions and 3 deletions
|
@ -3626,6 +3626,8 @@ class TestHelpUsage(HelpTestCase):
|
|||
Sig('--bar', help='Whether to bar', default=True,
|
||||
action=argparse.BooleanOptionalAction),
|
||||
Sig('-f', '--foobar', '--barfoo', action=argparse.BooleanOptionalAction),
|
||||
Sig('--bazz', action=argparse.BooleanOptionalAction,
|
||||
default=argparse.SUPPRESS, help='Bazz!'),
|
||||
]
|
||||
argument_group_signatures = [
|
||||
(Sig('group'), [
|
||||
|
@ -3638,8 +3640,8 @@ class TestHelpUsage(HelpTestCase):
|
|||
usage = '''\
|
||||
usage: PROG [-h] [-w W [W ...]] [-x [X ...]] [--foo | --no-foo]
|
||||
[--bar | --no-bar]
|
||||
[-f | --foobar | --no-foobar | --barfoo | --no-barfoo] [-y [Y]]
|
||||
[-z Z Z Z]
|
||||
[-f | --foobar | --no-foobar | --barfoo | --no-barfoo]
|
||||
[--bazz | --no-bazz] [-y [Y]] [-z Z Z Z]
|
||||
a b b [c] [d ...] e [e ...]
|
||||
'''
|
||||
help = usage + '''\
|
||||
|
@ -3656,6 +3658,7 @@ class TestHelpUsage(HelpTestCase):
|
|||
--foo, --no-foo Whether to foo
|
||||
--bar, --no-bar Whether to bar (default: True)
|
||||
-f, --foobar, --no-foobar, --barfoo, --no-barfoo
|
||||
--bazz, --no-bazz Bazz!
|
||||
|
||||
group:
|
||||
-y [Y] y
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue