8000 gh-127873: Only check `sys.flags.ignore_environment` for `PYTHON*` env vars by hugovk · Pull Request #127877 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-127873: Only check sys.flags.ignore_environment for PYTHON* env vars #127877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Only check sys.flags.ignore_environment before PYTHON\* env vars
  • Loading branch information
hugovk committed Dec 12, 2024
commit 71df92068f68538a1a602bf59099a78ec81f4baf
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number 8000 Diff line number Diff line change
Expand Up @@ -295,3 +295,7 @@ Lib/test/test_configparser.py @jaraco
Doc/reference/ @willingc

**/*weakref* @kumaraditya303

# Colorize
Lib/_colorize.py @hugovk
Lib/test/test__colorize.py @hugovk
13 changes: 6 additions & 7 deletions Lib/_colorize.py
8999
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@ def can_colorize() -> 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(sys.stderr, "fileno"):
return False
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When ``-E`` is set, only ignore ``PYTHON_COLORS`` and not
``FORCE_COLOR``/``NO_COLOR``/``TERM`` when colourising output.
Patch by Hugo van Kemenade.
0