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 incorrectly colored error locations when wide unicode characters exists by HarryLHW · Pull Request #130277 · python/cpython Conversation
|
| for i in range(start, len(line)): | ||
| if width <= 0: | ||
| return i, line[start:i] | ||
| width -= 2 if east_asian_width(line[i]) in _WIDE_CHAR_SPECIFIERS else 1 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
does this correctly handle zero-width characters? e.g. the '\u0301' from 'cafe\u0301'
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.
No.
However, _display_width() does not correctly handle zero-width characters for carets positions either.
>>> café = 1/0 Traceback (most recent call last): File "<python-input-0>", line 1, in <module> café = 1/0 ~^~ ZeroDivisionError: division by zero >>>
They can be fixed in the same way. I wonder how I can find all the zero-width characters.
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.
It looks like there are many zero-width characters: https://wcwidth.readthedocs.io/en/latest/specs.html#width-of-0
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 is how wcwidth implements wcswidth() and wcwidth(): https://wcwidth.readthedocs.io/en/latest/_modules/wcwidth/wcwidth.html#wcswidth
Maybe it is too complicated for our traceback? Could we have a simple way that can handle most of the cases?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Going with #142529 instead. |
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.