GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-128595: Default to stdout isatty for colour detection instead of stderr by hugovk · Pull Request #128498 · python/cpython Conversation
|
| Before | After |
|---|---|
|
|
|
|
|
|
|
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Should this be considered a bugfix to backport to 3.13, with its own issue and NEWS, or piggyback on gh-128317 for 3.14 only? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I would say it deserves an issue and a NEWS entry. I'm fine with adding it to #128317 if it's not going to be backported. I'm leaning into calling it a bugfix. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Issue, NEWS and backport label applied. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Agree this sounds like a bug to me :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Why not check this for stdout and stderr separately? If the traceback is written to terminal, it should be colorized. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
For example, something like this? -def can_colorize() -> bool: +def can_colorize(file=sys.stdout) -> bool: if not sys.flags.ignore_environment: if os.environ.get("PYTHON_COLORS") == "0": return False @@ -49,7 +49,7 @@ def can_colorize() -> bool: if os.environ.get("TERM") == "dumb": return False - if not hasattr(sys.stdout, "fileno"): + if not hasattr(file, "fileno"): return False if sys.platform == "win32": @@ -62,6 +62,6 @@ def can_colorize() -> bool: return False try: - return os.isatty(sys.stdout.fileno()) + return os.isatty(file.fileno()) except io.UnsupportedOperation: return sys.stdout.isatty() And then places like def _print_exception_bltin(exc, /):
file = sys.stderr if sys.stderr is not None else sys.__stderr__
- colorize = _colorize.can_colorize()
+ colorize = _colorize.can_colorize(file=file)
return print_exception(exc, limit=BUILTIN_EXCEPTION_LIMIT, file=file, colorize=colorize) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yes, except that dynamic value |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Can you extract the code to disable colors as a separated PR and merge it first? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sure! Please see PR #128687. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Now merged, making this PR much simpler. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Please implement what was discussed above. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks again for the reviews! Next to update #127877. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, @hugovk, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… instead of stderr (pythonGH-128498) (cherry picked from commit 6f167d7) Co-authored-by: Hugo van Kemenade <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
… instead of stderr (pythonGH-128498) (cherry picked from commit 6f167d7) Co-authored-by: Hugo van Kemenade <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
|
GH-129057 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Some build bots are now failing (https://buildbot.python.org/api/v2/logs/12166870/raw_inline):
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Please see PR #129070 for a fix. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…d of stderr (python#128498) Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
…ad of stderr (GH-128498) (#129057) Co-authored-by: Hugo van Kemenade <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: Victor Stinner <[email protected]> Fix `test__colorize` unexpected keyword argument 'file' on buildbots (#129070)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.