diff options
author | Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> | 2025-01-21 18:10:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-21 16:10:08 +0000 |
commit | 05d12eecbde1ace39826320cadf8e673d709b229 (patch) | |
tree | 2e767c71374e498d1f9759e2ba60177152b396d0 /Lib/_colorize.py | |
parent | 13475e0a5a317fa61f302f030b0effcb021873d6 (diff) | |
download | cpython-05d12eecbde1ace39826320cadf8e673d709b229.tar.gz cpython-05d12eecbde1ace39826320cadf8e673d709b229.zip |
gh-127873: Only check `sys.flags.ignore_environment` for `PYTHON*` env vars (#127877)
Diffstat (limited to 'Lib/_colorize.py')
-rw-r--r-- | Lib/_colorize.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Lib/_colorize.py b/Lib/_colorize.py index bab2e599b2c..5e36e45734a 100644 --- a/Lib/_colorize.py +++ b/Lib/_colorize.py @@ -42,15 +42,14 @@ def can_colorize(*, file=None) -> bool: return False if os.environ.get("PYTHON_COLORS") == "1": return True - if "NO_COLOR" in os.environ: - return False + if "NO_COLOR" in os.environ: + return False if not COLORIZE: return False - if not sys.flags.ignore_environment: - if "FORCE_COLOR" in os.environ: - return True - if os.environ.get("TERM") == "dumb": - return False + if "FORCE_COLOR" in os.environ: + return True + if os.environ.get("TERM") == "dumb": + return False if not hasattr(file, "fileno"): return False |