-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Python3.13 is mishandling OSC 633 sequences #126131
Copy link
Copy link
Closed as not planned
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard 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
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard 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
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:

After investigation we found out it is because Python3.13 is somehow handling our custom sequences such as
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=1CPython 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)