We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
can_colorize()
FORCE_COLOR
NO_COLOR
TERM
-E
Using one of the FORCE_COLOR, NO_COLOR or TERM=dumb environment variables is ignored when you use Python with -E.
TERM=dumb
-E means:
Ignore all PYTHON* environment variables, e.g. PYTHONPATH and PYTHONHOME, that might be set.
PYTHON*
The -E is stored in sys.flags.ignore_environment.
sys.flags.ignore_environment
sys.flags.ignore_environment is used to ignore PYTHON_COLORS (correct) but it's also ignoring these other env vars (incorrect).
PYTHON_COLORS
For example, this is not colourised, as expected:
❯ NO_COLOR=1 python3.13 -c 1/0 Traceback (most recent call last): File "<string>", line 1, in <module> 1/0 ~^~ ZeroDivisionError: division by zero
However, NO_COLOR=1 is ignored when passing -E and the output has colour when it should not:
NO_COLOR=1
❯ NO_COLOR=1 python3.13 -E -c 1/0 Traceback (most recent call last): File "<string>", line 1, in <module> 1/0 ~^~ ZeroDivisionError: division by zero
This bit needs updating:
cpython/Lib/_colorize.py
Lines 43 to 56 in 487fdbe
3.13, 3.14
Linux, macOS, Windows
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug report
Bug description:
Using one of the
FORCE_COLOR
,NO_COLOR
orTERM=dumb
environment variables is ignored when you use Python with-E
.-E
means:The
-E
is stored insys.flags.ignore_environment
.sys.flags.ignore_environment
is used to ignorePYTHON_COLORS
(correct) but it's also ignoring these other env vars (incorrect).For example, this is not colourised, as expected:
However,
NO_COLOR=1
is ignored when passing-E
and the output has colour when it should not:This bit needs updating:
cpython/Lib/_colorize.py
Lines 43 to 56 in 487fdbe
CPython versions tested on:
3.13, 3.14
Operating systems tested on:
Linux, macOS, Windows
Linked PRs
sys.flags.ignore_environment
forPYTHON*
env vars #127877The text was updated successfully, but these errors were encountered: