GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — 3.14+ argparse colorization makes sub-commands prog always colored if colored at creation time · Issue #139809 · python/cpython Closed Labels 3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportBug description:Here's an example script that replicates the problem: from __future__ import annotations import os from argparse import ArgumentParser from contextlib import suppress from unittest.mock import patch os.environ["FORCE_COLOR"] = "1" parser = ArgumentParser(description="argparse tester", prog="complex") parser.add_argument("--root", action="store_true", help="root flag") sub = parser.add_subparsers(dest="command") sub.add_parser("demo") with suppress(SystemExit): parser.parse_args(["demo", "--help"]) with patch.dict(os.environ, {"NO_COLOR": "1"}, clear=False): parser.parse_args(["demo", "--help"]) You can see the first invocation prints everything in color, while the second only the sub-command:
This is because https://github.com/python/cpython/blame/main/Lib/argparse.py#L1966 passes through the CPython versions tested on:3.14, 3.15 Operating systems tested on:Linux, macOS Linked PRsActivity
MetadataMetadataAssigneesLabels3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error Projects
MilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |