Skip to content

Python3.13 is mishandling OSC 633 sequences #126131

Open
@anthonykim1

Description

@anthonykim1

Bug report

Bug description:

Bug Report

Related: #122622

Bug description:

VS Code has set of custom escape sequences that allow shell integration.

We have a custom pythonrc file that we set equal to user's PYTHONSTARTUP file and effectively override user's sys.ps1(this can be improved once we have the pre-exec hook mentioned in the related PR) This allows us to get features that VS Code shell integration offers.

With the new REPL that 3.13 offers, we have noticed that the cursor location is wrongly placed whenever REPL from Python3.13 is launched from our terminal. See:
Screenshot 2024-10-29 at 8 48 48 AM

After investigation we found out it is because Python3.13 is somehow handling our custom sequences such as

command_line="\x1b]633;E;" + str(get_last_command()) + "\x07",

instead of ignoring them as it did in the previous versions of Python. This is what is leads to the wrong cursor location at the end. Removing these sequences brought back the cursor to the "right" position in terminal.

CPython should ignore these custom sequences instead of wrongly handling them.

Edit: Workaround could be temporarily disabling PyREPL via env var injection
exporting PYTHON_BASIC_REPL=1

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Linked PR

coming soon (would appreciate advice on where to start digging in but I assume it is somewhere https://github.com/python/cpython/tree/main/Lib/_pyrepl)

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixesstdlibPython modules in the Lib dirtopic-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