Skip to content

A multi-byte character in new PyREPL requires two backspaces to delete #142162

Description

@grayjk

Bug report

Bug description:

Bug report

To reproduce

  1. Open the new REPL
  2. Paste: é
  3. Backspace to remove the pasted character

The paste-able string above is letter 'e' followed by \u0301. To create it use:

print('e\u0301')

The \u0301 is a combining mark with zero-width display length

Current behavior

Two backspaces are required to remove the displayed character

Expected behavior

One backspace is required to remove the displayed character

This is the behavior in the old REPL

CPython versions tested on:

3.14.0, 3.15.0a2

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Dec 1, 2025
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    topic-replRelated to the interactive shell
    on Dec 1, 2025
  3. typenoob commented on Dec 2, 2025

    @typenoob

    Seems a change with the new colored REPL since 3.13 (#111201)

    Extra Info: Node.js REPL also requires two backspaces to delete. Do others think this is problematic?

  4. typenoob commented on Dec 2, 2025

    @typenoob

    Interestingly, there seems two different é
    copy this é(\xe9) and it requires single backspace to delete.
    copy this é(e\u0301) and it requires two backspaces.

  5. yihong0618 commented on Dec 2, 2025

    @yihong0618
    Contributor

    This is as expected I tried other repl like node and ipython
    they are the same behavior.

  6. typenoob commented on Dec 3, 2025

    @typenoob

    I also agree it's the right behavior.

    After some searches and tries, I discover the fact that, ́ (\u0301) this is the Combining Acute Accent. It can come after any char, though it may behave very strange when come after non-letter char.

    And when it came after a letter like é, it merged automatically. However, it still two chars and apparently need two backspaces to delete (even in github comment area)

    However I believe there's something odd in the new REPL as you can see a unexpected space came after é. I can open a new issue about this.

    Image
  7. grayjk commented on Dec 3, 2025

    @grayjk
    ContributorAuthor

    @typenoob compare the behavior of the old REPL with the new REPL. The behavior should be the same - one backspace to delete the combined character

  8. grayjk commented on Dec 3, 2025

    @grayjk
    ContributorAuthor

    in the new REPL as you can see a unexpected space came after é.

    @typenoob the space after issue was addressed in #139246 which is fixed in 3.14.1 and 3.15.0a2

  9. typenoob commented on Dec 3, 2025

    @typenoob

    @typenoob compare the behavior of the old REPL with the new REPL. The behavior should be the same - one backspace to delete the combined character

    In cmd, it's one backspace.
    In powershell, it's two backspaces.
    In bash, it's one backspace.

    It behaves differently among the interactive shells and their versions, some requires two, but some requires one.

    Also behaves differently among text edit softwares

    We should make a specification for it.
    Is there any existing spec we can follow, or we can make a spec to restrict the behavior for CPython?

  10. picnixz commented on Dec 6, 2025

    @picnixz
    Member

    e\u0301 is a string of 2 characters which then becomes a glyph looking like 1 character. But it's still 2 characters, not 1, so we could say that it's also fine (one backspace = one character to delete).

    Is there any existing spec we can follow, or we can make a spec to restrict the behavior for CPython?

    That's what we call "Combining characters" in the Unicode standard. So we could filter which characters to delete in one go.


    Now, the alternative would be to simply check if the character that was removed is a combining character and, if so, continue deleting. I'll try to see if such patch is easy to do or not.

  11. self-assigned this
    on Dec 6, 2025
  12. added
    3.13only security fixes
    3.14bugs and security fixes
    3.15bugs and security fixes
    on Dec 6, 2025
  13. picnixz commented on Dec 6, 2025

    @picnixz
    Member

    By the way, this doesn't just affect backspace, it also affects navigation. In the old REPL, navigating with arrows skipped combining characters (which is likely readline behavior) while with the new REPL, we need two keystrokes

  14. removed their assignment
    on Dec 27, 2025
  15. picnixz commented on Dec 27, 2025

    @picnixz
    Member

    I'm removing my assignment because (1) I wasn't able to come up with an elegant solution (2) I have other tasks of higher priority. I think a REPL expert should decide what to do here.

    cc @pablogsal @ambv

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixes3.14bugs and security fixes3.15bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions