Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-130273: Fix incorrectly colored error locations when wide unicode characters exists#130277

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
HarryLHW wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromHarryLHW:traceback-colors

Conversation

HarryLHW
Copy link
Contributor

@HarryLHWHarryLHW commentedFeb 18, 2025
edited by bedevere-appbot
Loading

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

Choose a reason for 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'

Copy link
ContributorAuthor

Choose a reason for 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/0Traceback (most recent call last):  File"<python-input-0>", line1, 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.

Choose a reason for 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

HarryLHW reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is howwcwidth implementswcswidth() andwcwidth():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?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@grayjkgrayjkgrayjk left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@HarryLHW@grayjk

[8]ページ先頭

©2009-2025 Movatter.jp