mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] gh-96310: Fix a traceback in argparse when all options in a mutually exclusive group are suppressed (GH-96311) (GH-115767)
Reproducer depends on terminal size - the traceback occurs when there's
an option long enough so the usage line doesn't fit the terminal width.
Option order is also important for reproducibility.
Excluding empty groups (with all options suppressed) from inserts
fixes the problem.
(cherry picked from commit 5f7df88821
)
Co-authored-by: Daniel Mach <daniel.mach@suse.com>
This commit is contained in:
parent
2ea2d25cc6
commit
dae7341da2
3 changed files with 25 additions and 0 deletions
|
@ -415,6 +415,8 @@ class HelpFormatter(object):
|
|||
suppressed_actions_count += 1
|
||||
|
||||
exposed_actions_count = group_action_count - suppressed_actions_count
|
||||
if not exposed_actions_count:
|
||||
continue
|
||||
|
||||
if not group.required:
|
||||
if start in inserts:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue