GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — New REPL on Windows exits when accented character is pasted/typed · Issue #131878 · python/cpython

New REPL on Windows exits when accented character is pasted/typed #131878

New issue
Copy link
New issue
Copy link
Closed
Closed
New REPL on Windows exits when accented character is pasted/typed#131878
Copy link
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesOS-windowsrelease-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@devdanzin
devdanzin
opened on Mar 29, 2025
Issue body actions

Crash report

What happened?

When pasting an accented character like ñ or é, or typing one such as ´p and pressing Enter, then up arrow, the new REPL on Windows will exit with the following error:

Python 3.14.0a6+ (heads/fix_non_string_candidates_exit_repl-dirty:8008a588342, Mar 29 2025, 08:15:) [MSC v.1943 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\__main__.py", line 6, in <module>
    __pyrepl_interactive_console()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\main.py", line 59, in interactive_console
    run_multiline_interactive_console(console)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\simple_interact.py", line 137, in run_multiline_interactive_console
    statement = multiline_input(more_lines, ps1, ps2)
  File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\readline.py", line 389, in multiline_input
    return reader.readline()
           ~~~~~~~~~~~~~~~^^
  File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\reader.py", line 750, in readline
    self.handle1()
    ~~~~~~~~~~~~^^
  File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\reader.py", line 706, in handle1
    event = self.console.get_event(block=False)
  File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\windows_console.py", line 471, in get_event
    self.event_queue.push(rec.Event.KeyEvent.uChar.UnicodeChar)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ddini\PycharmProjects\cpython\Lib\_pyrepl\base_eventqueue.py", line 88, in push
    assert len(self.buf) == 1
           ^^^^^^^^^^^^^^^^^^
AssertionError

In these cases, len(self.buf) is 3 instead of 1.

I'm running Python in Windows Terminal, chcp gives 850, changing it to 65001 (UTF-8) makes no difference.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Output from running 'python -VV' on the command line:

Python 3.14.0a6+ (heads/main-dirty:7c3692fe275, Mar 24 2025, 19:20:37) [MSC v.1942 64 bit (AMD64)]

Linked PRs

  • gh-131878: Fix input of unicode characters with two or more code points in new pyrepl on Windows #131901
  • gh-131878: Handle top level exceptions in new pyrepl and prevent of closing it #131910
  • gh-131878: Fix input of unicode characters with two or more code points in the REPL on Windows in vt mode #133030
  • [3.13] gh-131878: Handle top level exceptions in new pyrepl and prevent of closing it (GH-131910) #133445
  • [3.13] gh-131878: Fix input of unicode characters with two or more code points in new pyrepl on Windows (gh-131901) #133468

Activity

Next
  1. devdanzin
    added
    type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
    on Mar 29, 2025
  2. StanFromIreland commented on Mar 29, 2025

    @StanFromIreland
    StanFromIreland
    on Mar 29, 2025
    Member
    More actions

    Related? #130273

    This is a bug and not a crash.

  3. devdanzin commented on Mar 29, 2025

    @devdanzin
    devdanzin
    on Mar 29, 2025
    MemberAuthor
    More actions

    This is a bug and not a crash.

    Correct, sorry about that.

    cc @DinoV, @y5c4l3, @encukou

  4. tomasr8
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-replRelated to the interactive shellRelated to the interactive shell
    and removed
    type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
    on Mar 29, 2025
  5. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Mar 29, 2025
  6. StanFromIreland commented on Mar 29, 2025

    @StanFromIreland
    StanFromIreland
    on Mar 29, 2025
    Member
    More actions

    This is os-windows specific. IIRC there was recently an issue about this, it was closed.

  7. StanFromIreland commented on Mar 29, 2025

    @StanFromIreland
    StanFromIreland
    on Mar 29, 2025
    Member
    More actions

    Yes looking at #130804 it seems it was not fully resolved, and it is presumably a side effect of the merged pr, do we want to reopen that?

  8. sergey-miryanov commented on Mar 29, 2025

    @sergey-miryanov
    sergey-miryanov
    on Mar 29, 2025
    Contributor
    More actions

    @StanFromIreland
    It is in another execution path, so I think this should be a new issue (despite it looks similar).

  9. StanFromIreland commented on Mar 29, 2025

    @StanFromIreland
    StanFromIreland
    on Mar 29, 2025
    Member
    More actions

    @sergey-miryanov

    cpython/Lib/_pyrepl/base_eventqueue.py

    Lines 72 to 89 in fccf9ab

    def push(self, char: int | bytes | str) -> None:
    """
    Processes a character by updating the buffer and handling special key mappings.
    """
    ord_char = char if isinstance(char, int) else ord(char)
    if ord_char > 255:
    assert isinstance(char, str)
    char = bytes(char.encode(self.encoding, "replace"))
    self.buf.extend(char)
    else:
    char = bytes(bytearray((ord_char,)))
    self.buf.append(ord_char)
    if char in self.keymap:
    if self.keymap is self.compiled_keymap:
    # sanity check, buffer is empty when a special key comes
    assert len(self.buf) == 1
    k = self.keymap[char]

    It is in the same path you modified, your changes are the last ones to modify the buffer before the check?

  10. picnixz
    added
    3.13only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    on Mar 29, 2025
  11. sergey-miryanov commented on Mar 29, 2025

    @sergey-miryanov
    sergey-miryanov
    on Mar 29, 2025
    Contributor
    More actions

    @StanFromIreland Oh, I get what you mean. Yes, it is related, but I think it is related to keymap and compiled_keymap also, so it extends my previous patch a bit. I will test and fix. Can you assign it to me?

  12. sergey-miryanov commented on Mar 29, 2025

    @sergey-miryanov
    sergey-miryanov
    on Mar 29, 2025
    Contributor
    More actions

    Also, I should mention that it is not backported to 3.13 due conflicts - #130805 (comment)

  13. 4 remaining items

  14. ezio-melotti
    added this to Release and Deferred blockers 🚫on Apr 15, 2025
  15. github-project-automation
    moved this to Todo in Release and Deferred blockers 🚫on Apr 15, 2025
  16. tomasr8
    added
    OS-windows
    on Apr 17, 2025
  17. sergey-miryanov
    added a commit that references this issue on Apr 26, 2025

    Merge branch 'main' into pythongh-131878-fix-unicode-input-in-new-pyr…

    a2fb7ee
  18. ambv
    added 4 commits that reference this issue on May 5, 2025

    gh-131878: Handle top level exceptions in new pyrepl and prevent of c…

    99a0d7e

    [3.13] pythongh-131878: Handle top level exceptions in new pyrepl and…

    b75310d

    [3.13] gh-131878: Handle top level exceptions in new pyrepl and preve…

    87b14c8

    gh-131878: Fix input of unicode characters with two or more code poin…

    0c5151b
  19. ambv commented on May 5, 2025

    @ambv
    ambv
    on May 5, 2025
    Contributor
    More actions

    Fixed, thank you all!

    Reacted by Chris Eibl, Hugo van Kemenade and Sergey Miryanov
  20. ambv
    closed this as completedon May 5, 2025
  21. github-project-automation
    moved this from Todo to Done in Release and Deferred blockers 🚫on May 5, 2025
  22. ambv
    added 2 commits that reference this issue on May 5, 2025

    [3.13] pythongh-131878: Fix input of unicode characters with two or m…

    1fcec66

    [3.13] gh-131878: Fix input of unicode characters with two or more co…

    891232f
  23. Pranjal095
    added 2 commits that reference this issue on Jul 12, 2025

    pythongh-131878: Handle top level exceptions in new pyrepl and preven…

    dce813c

    pythongh-131878: Fix input of unicode characters with two or more cod…

    ac6b151
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 fixesonly security fixes3.14bugs and security fixesbugs and security fixesOS-windowsrelease-blockerstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • Release and Deferred blockers 🚫
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.