Skip to content
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

Empty values of FORCE_COLOR and NO_COLOR are not ignored #129061

Closed
serhiy-storchaka opened this issue Jan 20, 2025 · 3 comments
Closed

Empty values of FORCE_COLOR and NO_COLOR are not ignored #129061

serhiy-storchaka opened this issue Jan 20, 2025 · 3 comments
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Jan 20, 2025

Bug report

Bug description:

https://no-color.org/

Command-line software which adds ANSI color to its output by default should check for a NO_COLOR environment variable that, when present and not an empty string (regardless of its value), prevents the addition of ANSI color.

https://force-color.org/

Command-line software which outputs colored text should check for a FORCE_COLOR environment variable. When this variable is present and not an empty string (regardless of its value), it should force the addition of ANSI color.

Both "standards" state that these environment variables has only effect if their value is not an empty string. But Python currently only tests that the environment variables are defined.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@serhiy-storchaka serhiy-storchaka added 3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error labels Jan 20, 2025
@serhiy-storchaka
Copy link
Member Author

cc @hugovk

@erlend-aasland
Copy link
Contributor

See also earlier discussion: #128318 (comment)

@hugovk
Copy link
Member

hugovk commented Jan 23, 2025

Please see PR #129140.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 27, 2025
…ythonGH-129140)

(cherry picked from commit 9546fe2ef2db921709f3cb355b33bba977658672)

Co-authored-by: Hugo van Kemenade <[email protected]>
hugovk added a commit that referenced this issue Jan 27, 2025
…GH-129140) (#129360)

gh-129061: Fix `FORCE_COLOR` and `NO_COLOR` when empty strings (GH-129140)
(cherry picked from commit 9546fe2)

Co-authored-by: Hugo van Kemenade <[email protected]>
@hugovk hugovk closed this as completed Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants