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 — Unicode characters ≥ 0x10000 cannot be inputted/behaves unusually at the REPL terminal. · Issue #136595 · python/cpython

Unicode characters ≥ 0x10000 cannot be inputted/behaves unusually at the REPL terminal. #136595

New issue
Copy link
New issue
Copy link
Open
#136639
Open
Unicode characters ≥ 0x10000 cannot be inputted/behaves unusually at the REPL terminal.#136595
#136639
Copy link
Labels
OS-windowsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltopic-unicodetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@haydenwong7bm
haydenwong7bm
opened on Jul 12, 2025
Issue body actions

Bug report

Bug description:

When the machine locale is set to UTF-8, when inputting a Unicode character ≥ 0x10000:
In CPython 3.13.5:
https://github.com/user-attachments/assets/7777b063-76fe-4929-b854-cae7d61807d2
In Cpython 3.14.0b4:

>>> Traceback (most recent call last):
  File "*\Python\Python314\Lib\_pyrepl\readline.py", line 394, in multiline_input
    return reader.readline()
           ~~~~~~~~~~~~~~~^^
  File "*\Python\Python314\Lib\_pyrepl\reader.py", line 748, in readline
    self.handle1()
    ~~~~~~~~~~~~^^
  File "*\Python\Python314\Lib\_pyrepl\reader.py", line 731, in handle1
    self.do_cmd(cmd)
    ~~~~~~~~~~~^^^^^
  File "*\Python\Python314\Lib\_pyrepl\reader.py", line 661, in do_cmd
    self.refresh()
    ~~~~~~~~~~~~^^
  File "*\Python\Python314\Lib\_pyrepl\reader.py", line 638, in refresh
    self.screen = self.calc_screen()
                  ~~~~~~~~~~~~~~~~^^
  File "*\Python\Python314\Lib\_pyrepl\completing_reader.py", line 261, in calc_screen
    screen = super().calc_screen()
  File "*\Python\Python314\Lib\_pyrepl\reader.py", line 315, in calc_screen
    colors = list(gen_colors(self.get_unicode()))
  File "*\Python\Python314\Lib\_pyrepl\utils.py", line 108, in gen_colors
    for color in gen_colors_from_token_stream(gen, line_lengths):
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "*\Python\Python314\Lib\_pyrepl\utils.py", line 168, in gen_colors_from_token_stream
    for prev_token, token, next_token in token_window:
                                         ^^^^^^^^^^^^
  File "*\Python\Python314\Lib\_pyrepl\utils.py", line 363, in prev_next_window
    window = deque((None, next(iterator)), maxlen=3)
                          ~~~~^^^^^^^^^^
  File "*\Python\Python314\Lib\tokenize.py", line 582, in _generate_tokens_from_c_tokenizer
    for info in it:
                ^^
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 0-1: surrogates not allowed
>>> Traceback (most recent call last):
  File "*\Python\Python314\Lib\_pyrepl\readline.py", line 394, in multiline_input
    return reader.readline()
           ~~~~~~~~~~~~~~~^^
  File "*\Python\Python314\Lib\_pyrepl\reader.py", line 748, in readline
    self.handle1()
    ~~~~~~~~~~~~^^
  File "*\Python\Python314\Lib\_pyrepl\reader.py", line 731, in handle1
    self.do_cmd(cmd)
    ~~~~~~~~~~~^^^^^
  File "*\Python\Python314\Lib\_pyrepl\reader.py", line 661, in do_cmd
    self.refresh()
    ~~~~~~~~~~~~^^
  File "*\Python\Python314\Lib\_pyrepl\reader.py", line 638, in refresh
    self.screen = self.calc_screen()
                  ~~~~~~~~~~~~~~~~^^
  File "*\Python\Python314\Lib\_pyrepl\completing_reader.py", line 261, in calc_screen
    screen = super().calc_screen()
  File "*\Python\Python314\Lib\_pyrepl\reader.py", line 315, in calc_screen
    colors = list(gen_colors(self.get_unicode()))
  File "*\Python\Python314\Lib\_pyrepl\utils.py", line 108, in gen_colors
    for color in gen_colors_from_token_stream(gen, line_lengths):
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "*\Python\Python314\Lib\_pyrepl\utils.py", line 168, in gen_colors_from_token_stream
    for prev_token, token, next_token in token_window:
                                         ^^^^^^^^^^^^
  File "*\Python\Python314\Lib\_pyrepl\utils.py", line 363, in prev_next_window
    window = deque((None, next(iterator)), maxlen=3)
                          ~~~~^^^^^^^^^^
  File "*\Python\Python314\Lib\tokenize.py", line 582, in _generate_tokens_from_c_tokenizer
    for info in it:
                ^^
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 0-1: surrogates not allowed

Two surrogates were "inputted" and so two UnicodeEncodeErrors.

CPython versions tested on:

3.13, 3.14

Operating systems tested on:

Windows

Linked PRs

  • gh-136595: Normalize surrogate pairs in REPL input to fix UnicodeEnco… #136639
Reacted by Ryan McCampbell

Activity

  1. haydenwong7bm
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jul 12, 2025
  2. StanFromIreland
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    topic-unicode
    topic-replRelated to the interactive shellRelated to the interactive shell
    on Jul 12, 2025
  3. serhiy-storchaka
    added
    OS-windows
    on Jul 13, 2025
  4. vedant713
    added a commit that references this issue on Jul 14, 2025

    pythongh-136595: Normalize surrogate pairs in REPL input to fix Unico…

    b9c4f77
  5. StanFromIreland
    marked Pasting non-BMP emoji into the REPL in Windows Terminal fails with UnicodeDecodeError #140788 as a duplicate of this issue on Oct 30, 2025
  6. WFLing-seaer commented on Nov 9, 2025

    @WFLing-seaer
    WFLing-seaer
    on Nov 9, 2025
    More actions

    I've met this problem too when trying to paste 𣳆㶔𤃫𣸎 to πython running on WinTerminal.
    btw in CLI which python command starts pasting the word won't cause crash though it can't be fully pasted.
    怎么哪里都有屏被轰坏.jpg

  7. WFLing-seaer commented on Nov 9, 2025

    @WFLing-seaer
    WFLing-seaer
    on Nov 9, 2025
    More actions

    I've met this problem too when trying to paste 𣳆㶔𤃫𣸎 to πython running on WinTerminal. btw in CLI which python command starts pasting the word won't cause crash though it can't be fully pasted. 怎么哪里都有屏被轰坏.jpg

    this indicates there must be something wwrong with πython+WinTerminal. maybe compatibility problems.

  8. StanFromIreland
    marked Windows REPL (_pyrepl) crashes with UnicodeEncodeError when pasting multiline code containing emoji #153361 as a duplicate of this issue on Jul 8, 2026
  9. picnixz
    marked Copying emoji causes error in Python 3.14 REPL #155788 as a duplicate of this issue on Aug 14, 2026
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

    OS-windowsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-replRelated to the interactive shellRelated to the interactive shelltopic-unicodetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — 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.