forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
triage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
Description
Type: Bug
Behaviour
When running a VS Code task, the venv activation command (& c:/path/to/.venv/Scripts/Activate.ps1) leaks into stdin instead of being executed as a shell command. This causes any input() call or stdin-reading command to receive the activation path as input, breaking interactive prompts.
This is probably a regression of #9374.
Steps to reproduce:
- Create a workspace with a Python venv (I used
uv venv .venv) - Select the venv interpreter in VS Code
- Create this debug script (
debug_stdin_leak.py):
import msvcrt
import sys
print("Checking stdin buffer for leaked data...")
leaked_chars = []
while msvcrt.kbhit():
char = msvcrt.getch()
leaked_chars.append(char)
if leaked_chars:
leaked_data = b"".join(leaked_chars).decode("utf-8", errors="replace")
print(f"\n❌ STDIN LEAK DETECTED!")
print(f"Leaked data ({len(leaked_chars)} chars):")
print(f" {repr(leaked_data)}")
else:
print("\n✅ No data leaked into stdin buffer.")- Create a task in
.vscode/tasks.json:
{
"label": "Debug: Check stdin leak",
"type": "shell",
"command": "${workspaceFolder}/.venv/Scripts/python.exe",
"args": ["debug_stdin_leak.py"],
"presentation": {
"reveal": "always",
"panel": "new",
"focus": true
},
"problemMatcher": []
}- Run the task (make sure to close any existing terminals first so a fresh one is created)
Expected: stdin should be empty
Actual:
Checking stdin buffer for leaked data...
❌ STDIN LEAK DETECTED!
Leaked data (79 chars):
'& c:/Users/.../.venv/Scripts/Activate.ps1\r'Environment:
OS: Windows 11
Shell: PowerShell
venv created with: uv
Workaround: Flush stdin before reading input using msvcrt.kbhit() / msvcrt.getch()
Diagnostic data
Details
2026-01-21 11:35:56.908 [info] Native locator: Refresh started
2026-01-21 11:35:56.999 [info] Native locator: Refresh finished in 673 ms
2026-01-21 11:35:57.437 [info] Native locator: Refresh started
2026-01-21 11:35:57.447 [info] Skipping ActivatedEnv Detection: process.env.VSCODE_CLI !== '1'
2026-01-21 11:35:57.478 [info] Python interpreter path: .\.venv\Scripts\python.exe
2026-01-21 11:36:01.339 [info] > pyenv which python
2026-01-21 11:36:01.340 [info] cwd: .
2026-01-21 11:36:02.389 [info] > conda info --json
2026-01-21 11:36:03.686 [info] Native locator: Refresh finished in 6249 ms
2026-01-21 11:36:07.857 [info] Starting Pylance language server.
2026-01-21 11:43:34.156 [info] Send text to terminal: & C:/Users/.../.venv/Scripts/Activate.ps1
Extension version: 2026.0.0
VS Code version: Code 1.108.1 (585eba7c0c34fd6b30faac7c62a42050bfbc0086, 2026-01-14T14:55:44.241Z)
OS version: Windows_NT x64 10.0.22631
Modes:
- Python version (& distribution if applicable, e.g. Anaconda): 3.12.9
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the
python.languageServersetting: Pylance
User Settings
languageServer: "Pylance"
Installed Extensions
| Extension Name | Extension Id | Version |
|---|---|---|
| amazon-q-vscode | ama | 1.107.0 |
| autodocstring | njp | 0.6.1 |
| aws-toolkit-vscode | ama | 3.93.0 |
| bash-ide-vscode | mad | 1.43.0 |
| black-formatter | ms- | 2025.2.0 |
| datawrangler | ms- | 1.24.0 |
| debugpy | ms- | 2025.19.2026011901 |
| docker | doc | 0.18.0 |
| even-better-toml | tam | 0.21.2 |
| git-graph | mhu | 1.30.0 |
| gitblame | wad | 11.2.0 |
| gitlens | eam | 17.9.0 |
| go | gol | 0.52.1 |
| js-debug | ms- | 1.105.0 |
| js-debug-companion | ms- | 1.1.3 |
| jupyter | ms- | 2025.9.1 |
| jupyter-keymap | ms- | 1.1.2 |
| jupyter-renderers | ms- | 1.3.0 |
| markdown-pdf | yza | 1.5.0 |
| tom | 1.2.2 | |
| powershell | ms- | 2025.4.0 |
| prettier-sql-vscode | inf | 1.6.0 |
| pylint | ms- | 2025.2.0 |
| python | ms- | 2026.0.0 |
| remote-containers | ms- | 0.437.0 |
| remote-explorer | ms- | 0.5.0 |
| remote-ssh | ms- | 0.122.0 |
| remote-ssh-edit | ms- | 0.87.0 |
| remote-wsl | ms- | 0.104.3 |
| ruff | cha | 2026.34.0 |
| rust-analyzer | rus | 0.3.2761 |
| rust-syntax | dus | 0.6.1 |
| sqltools | mtx | 0.28.5 |
| sqltools-driver-mysql | mtx | 0.6.6 |
| sqltools-driver-pg | mtx | 0.5.7 |
| vscode-containers | ms- | 2.3.0 |
| vscode-github-actions | git | 0.29.1 |
| vscode-icons | vsc | 12.17.0 |
| vscode-js-profile-table | ms- | 1.0.10 |
| vscode-jupyter-cell-tags | ms- | 0.1.9 |
| vscode-jupyter-slideshow | ms- | 0.1.6 |
| vscode-nushell-lang | The | 1.10.0 |
| vscode-pylance | ms- | 2025.10.4 |
| vscode-python-envs | ms- | 1.17.10151015 |
| vscode-typescript-next | ms- | 6.0.20260120 |
| vscode-xml | red | 0.29.0 |
Metadata
Metadata
Assignees
Labels
triage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team