-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python3.13 is mishandling OSC 633 sequences #126131
Labels
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
stdlib
Python modules in the Lib dir
topic-repl
Related to the interactive shell
type-bug
An unexpected behavior, bug, or error
Comments
anthonykim1
changed the title
Python3.13 is wrongly handling OSC 633 sequences
Python3.13 is mishandling OSC 633 sequences
Oct 29, 2024
To clarify, the problem is that any interpreter of escape sequences should be ignoring any OSC sequence it does not understand. |
Eclips4
added
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
topic-repl
Related to the interactive shell
labels
Oct 29, 2024
31 tasks
anthonykim1
added a commit
to microsoft/vscode-python
that referenced
this issue
Dec 9, 2024
Further resolves: #24422 Prevent keyboard interrupt for Mac and Linux when using Python3.13 Having Python3.13 as interpreter choice and then enabling shell integration where it is normally supported (we disabled temporarily for Python3.13 due to python/cpython#126131), lead to edge case. So although we don't override user's PS1 in Python side after checking Python3.13 is selected, we were not aware of this in typescript side, leading to wrongly using executeCommand inside Python terminal REPL (Python3.13 IDLE), instead of sendText.
23 tasks
This was referenced Jan 31, 2025
Merged
anthonykim1
added a commit
to microsoft/vscode-python
that referenced
this issue
Feb 4, 2025
…24765) Resolves: #24674 (comment) Use sendText to send Python code to Terminal REPL for Python >= 3.13 to prevent keyboard interrupt. Relevant file context from VS Code: https://github.com/microsoft/vscode/blob/f9c927cf7a29a59b896b6cdac2d8b5d2d43afea5/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts#L906 It seems like we are on this edge scenario where generic terminal shell integration is enabled (so executeCommand can be used), but we have temporarily disabled Python shell integration for Python >= 3.13 (and of course sending the relevant escape sequences such as the commandLine itself to VS Code). Why? * python/cpython#126131 placing user's mouse cursor position at odd place. Why and where I think the keyboard interrupt is happening: Python extension tries to executeCommand when sending commands to terminal REPL >= Python3.13, where we are not sending shell integration escape sequences from the Python side. * I think this is why it is attaching the keyboard interrupt all the sudden, because VS Code see that Python extension is requesting executeCommand but is not sending the commandLine escape sequence to them. For every other versions < 3.13 (where we send all the shell integration escape sequences including the commandLine), this does not happen.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
stdlib
Python modules in the Lib dir
topic-repl
Related to the interactive shell
type-bug
An 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.
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)
The text was updated successfully, but these errors were encountered: