From 05d12eecbde1ace39826320cadf8e673d709b229 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 21 Jan 2025 18:10:08 +0200 Subject: gh-127873: Only check `sys.flags.ignore_environment` for `PYTHON*` env vars (#127877) --- Lib/_colorize.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'Lib/_colorize.py') 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 -- cgit v1.2.3