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-112730: Use color to highlight error locations by pablogsal · Pull Request #112732 · python/cpython Conversation
|
|
On Windows in both CommandPrompt and PowerShell, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Will investigate how to properly set this up for windows. I know the more modern Windows terminal (https://apps.microsoft.com/detail/9N0DX20HK701?hl=en-gb&gl=US) handles this correctly. We may need to deactivate this unless that new terminal is detected |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I think for the start I will look at We can iterate afterwards if someone want to add support to detecting other (working) environments. Or maybe we can expose some C calls to windows and check for |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
According to https://en.wikipedia.org/wiki/Windows_Terminal, the first stable release of Windows Terminal was 18 days ago. It can run Command Prompt, Powershell, WSL Bash, and more. It is becoming default on Win 11 and can be installed on up-to-date Win 10. I will see if either an option 'cumulative update preview' or the next monthly update (in a week) installs it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Excellent idea. Based on my experience in trying to support this type of feature in various terminal themes for friendly-traceback, I think it would be helpful if the colors in could also be user-configurable via environment variables or some other method. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Thanks a lot for the suggestion. I will consider it, but for the first version, I am going to center on getting the defaults right for most environments and then we can iterate to improve the situation in different systems. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@terryjreedy I have exposed a call to powershellwindows terminal |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Signed-off-by: Pablo Galindo <[email protected]>
58ce57a to
9ae4c77
Compare
|
Some Python programs use https://github.com/tartley/colorama for colour, and some others do the colour themselves but still depend on colorama just to call their https://github.com/tartley/colorama#initialisation You could check what that does, or their newer |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
That seems to wrap stderr and stdout to translate between ANSI and whatever windows uses. Given that this is critical code (we are printing errors) I don't want to mess with the standard streams not call complicated code. Also, it is not clear to me what will happen if the interpreter does this wrapping and then something else does it on top (notice the only reason they claim is safe to call multiple times is because they record global state). As mentioned before, I want to leave this as dumb as possible and the current solution that detects if is possible to use ANSI sequences seems to work nicely to detect when is safe to do. Edit: Also seems that the future for Windows is the "Windows terminal" that supports this out of the box. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Signed-off-by: Pablo Galindo <[email protected]>
|
With fresh update, after "Fix multiline output", tracebacks look normal (b/w, not ansi) in Python started in CommandPrompt and in Windows Console (when started from icon or Explorer). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Python-specific environment variables usually don't include underscores in their names (e.g. we have |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@barneygale, if you look at the current makeup of PYTHON env variables, you'll notice we are currently changing this naming scheme. New variables have an underscore to improve readability. We leave old ones as is for backwards compatibility. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ah ha! Thanks :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
) Signed-off-by: Pablo Galindo <[email protected]> Co-authored-by: Łukasz Langa <[email protected]>
| return self._str | ||
|
|
||
| def format_exception_only(self, *, show_group=False, _depth=0): | ||
| def format_exception_only(self, *, show_group=False, _depth=0, **kwargs): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to use **kwargs instead of *, colorlize=False?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The colorize parameter currently doesn't appear anywhere in the docs and it would now be a backwards-incompatible change to replace **kwargs with colorize=False
This was a good comment.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
) Signed-off-by: Pablo Galindo <[email protected]> Co-authored-by: Łukasz Langa <[email protected]>
| occurred with a caret on the next line indicating the approximate | ||
| position of the error. | ||
| """ | ||
| colorize = kwargs.get("colorize", False) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should add documentation for this argument. See #142896 142896
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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.