Skip to content

Conversation

@yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Sep 23, 2025

@yihong0618 yihong0618 changed the title fix: zero-width word paste can be wrong in default repl gh-139246: zero-width word paste can be wrong in default repl Sep 23, 2025
Signed-off-by: yihong0618 <[email protected]>
@yihong0618 yihong0618 requested a review from grayjk September 24, 2025 00:14
@yihong0618 yihong0618 marked this pull request as ready for review September 24, 2025 00:14

@functools.cache
def str_width(c: str) -> int:
if ord(c) < 128:
Copy link
Contributor

Choose a reason for hiding this comment

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

unrelated to this issue but quite a few of the characters with ord < 128, do not have a display width of 1

for example, in my terminal, tab (ord 9) is 8 charaters wide

something to consider for a future PR

category = unicodedata.category(c)
if category == "Cf" and c != "\u00ad":
return 0
if "\u2028" <= c <= "\u2029":
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, what terminal are you using? Here (on VTE) these take up one cell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mac with kitty

Copy link
Contributor

Choose a reason for hiding this comment

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

if \u2028 and \u2029 aren't consistent across terminals, could remove this condition since it is unrelated to the original issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

of course will do it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Signed-off-by: yihong0618 <[email protected]>
@encukou encukou merged commit 4e6dba0 into python:main Oct 30, 2025
58 checks passed
@encukou encukou added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Oct 30, 2025
@miss-islington-app
Copy link

Thanks @yihong0618 for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @yihong0618 for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @yihong0618 and @encukou, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 4e6dba0ef74523a52f66547c16b9972664b18fd4 3.13

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 30, 2025
…ythonGH-139254)

(cherry picked from commit 4e6dba0)

Co-authored-by: yihong <[email protected]>
Signed-off-by: yihong0618 <[email protected]>
Co-authored-by: grayjk <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Oct 30, 2025

GH-140796 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Oct 30, 2025
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Nov 6, 2025
… repl (pythonGH-139254)

(cherry picked from commit 4e6dba0)

Co-authored-by: yihong <[email protected]>
Signed-off-by: yihong0618 <[email protected]>
Co-authored-by: grayjk <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Nov 6, 2025

GH-141166 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Nov 6, 2025
encukou pushed a commit that referenced this pull request Nov 7, 2025
…H-139254) (GH-140796)

gh-139246: zero-width word paste can be wrong in default repl (GH-139254)

(cherry picked from commit 4e6dba0)

Signed-off-by: yihong0618 <[email protected]>
Co-authored-by: yihong <[email protected]>
Co-authored-by: grayjk <[email protected]>
encukou pushed a commit that referenced this pull request Nov 7, 2025
…H-139254) (GH-141166)

(cherry picked from commit 4e6dba0)

Signed-off-by: yihong0618 <[email protected]>
Co-authored-by: yihong <[email protected]>
Co-authored-by: grayjk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants