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-130273: Fix traceback color output with unicode characters by grayjk · Pull Request #142529 · python/cpython Conversation
|
|
@serhiy-storchaka: Here is a PR about text width and Unicode characters :-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
updated to use @serhiy-storchaka's recently added unicodedata.iter_graphemes |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@pablogsal @hauntsaninja as recent reviewers of traceback.py, would you mind taking look |
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 are conflicts again I'm afraid, and mypy isn't happy either. |
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.
There was an error while loading. Please reload this page.
|
@pablogsal You maybe make wrong something :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for your PR. I reverted the move of string-handling utils to traceback, they don't belong there This is because mypy type-checking introduction to the standard library relies on introduction of fully type-annotated libraries. I intend to keep it that way and therefore sprinkling It is now out of scope to format all of There's also a related behavioral change in |
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.
This PR fixes misaligned color highlighting/underlining in traceback output when the source line contains wide Unicode characters or grapheme clusters, by switching caret/column calculations to use display width rather than raw character offsets.
Changes:
_display_width() to use _wlen()/_str_width() logic (including CTRL-Z and ANSI escape sequence handling) and adds targeted tests for wide/combining/ASCII edge cases.Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Misc/NEWS.d/next/Library/2025-12-10-15-15-09.gh-issue-130273.iCfiY5.rst | Announces the traceback color alignment fix for Unicode characters. |
| Lib/traceback.py | Implements grapheme/display-width-aware caret-to-text alignment and updates width calculation helpers. |
| Lib/test/test_traceback.py | Adds regression tests for colorized tracebacks with wide/combining Unicode and ASCII display-width edge cases. |
| Lib/_pyrepl/utils.py | Minor whitespace-only change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
|
Sorry, @grayjk and @ambv, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, @grayjk and @ambv, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
There's some trivial conflicts that can be solved here, but the real problem is that WDYT, @serhiy-storchaka, is it worth creating a pure Python version of this segmentation purely for the backports? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
To help you decide, I created #148218 so you can see what the implementation would look like. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ythonGH-142529) Account for the display width of Unicode characters so that colors and underlining in traceback output is correct. Co-authored-by: Łukasz Langa <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Traceback colors are shifted when the line contains wide unicode characters
There was an error while loading. Please reload this page.