mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
[3.14] GH-139809: Fix argparse subcommand prog not respecting color environment variables (GH-139818) (#139866)
GH-139809: Fix argparse subcommand prog not respecting color environment variables (GH-139818)
(cherry picked from commit 9fc4366f09)
Co-authored-by: Savannah Ostrowski <savannah@python.org>
This commit is contained in:
parent
2cc13ff304
commit
af1cb1cdb8
3 changed files with 18 additions and 2 deletions
|
|
@ -1960,7 +1960,9 @@ def add_subparsers(self, **kwargs):
|
|||
# prog defaults to the usage message of this parser, skipping
|
||||
# optional arguments and with no "usage:" prefix
|
||||
if kwargs.get('prog') is None:
|
||||
formatter = self._get_formatter()
|
||||
# Create formatter without color to avoid storing ANSI codes in prog
|
||||
formatter = self.formatter_class(prog=self.prog)
|
||||
formatter._set_color(False)
|
||||
positionals = self._get_positional_actions()
|
||||
groups = self._mutually_exclusive_groups
|
||||
formatter.add_usage(None, positionals, groups, '')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue