microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.5k stars 29.38k forks source link

KeyboardInterrupt #233622

Open ptoche opened 6 days ago

ptoche commented 6 days ago

I get a "KeyboardInterrupt" message in the console upon executing code. I usually execute with the shortcut below, but the same behavior occurs when I click on the "run" icon (top-right corner).

Image

Steps to Reproduce:

  1. Start VS Code.
  2. Create a new file with a simple command like "import os".
  3. Execute it

output:

/Users/username/miniconda3/envs/da/bin/python
(da) (base) username@Patricks-MacBook-Pro-3 ~ % /Users/username/miniconda3/envs/da/bin/python
Python 3.12.7 | packaged by conda-forge | (main, Oct  4 2024, 15:57:01) [Clang 17.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
KeyboardInterrupt
>>> import os
>>> 

I am observing this the day after I upgraded to MacOS Sequoia, so presumably a connection there.

My keyboard shortcut for reference:

{
    "key": "f12",
    "command": "python.execSelectionInTerminal",
    "when": "editorTextFocus && !findInputFocussed && !jupyter.ownsSelection && !notebookEditorFocused && !replaceInputFocussed && editorLangId == 'python'"
},
scottrjackson commented 4 days ago

I was having the issue across multiple platforms (macOS Sonoma, Windows 11, and Pop_OS! Linux), using SmartSend (Shift+Enter).

However, it seems to be related to the Microsoft-distributed Python Extension. Using the most current version of Code (1.95.2), I can replicate the problem with extension v2024.18.1 and v2024.20.0. But if I instead install v2024.18.0 or earlier, the KeyboardInterrupt issue does not occur.

So something introduced starting with the extension v18.1 or later may be causing the problem.