Skip to content

fix: do not pass redundant quotes to script path in executeUsingExtension (#26274) - #26276

Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:fix-26274-run-file-path-spaces
Open

MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:fix-26274-run-file-path-spaces

Conversation

@wasim-builds

Copy link
Copy Markdown

Summary

Fixes #26274
Also resolves the underlying issue reported upstream in microsoft/vscode#346333.

When "Run Python File" or "Run Python File in Dedicated Terminal" executes via the Python Environments extension API (extapi.runInTerminal or extapi.runInDedicatedTerminal), PythonTerminalExecutionOptions.args expects raw arguments and handles necessary shell quoting internally.

Previously, executeUsingExtension in src/client/terminals/codeExecution/codeExecutionManager.ts appended fileToExecute.fsPath.fileToCommandArgumentForPythonExt() to totalArgs. For script paths containing spaces (e.g. /path with spaces/main.py), fileToCommandArgumentForPythonExt() wrapped the path in literal quotes ("..."). When passed to runInTerminal, the terminal received literal quotes as part of the path, causing Python to fail with [Errno 2] No such file or directory or [Errno 22] Invalid argument: '"/path with spaces/main.py"'.

Changes

  1. In src/client/terminals/codeExecution/codeExecutionManager.ts:
    • Pass raw fileToExecute.fsPath in totalArgs instead of wrapping with fileToCommandArgumentForPythonExt(), letting the terminal execution API handle argument quoting.
  2. In src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts:
    • Added unit test Ensure executeUsingExtension does not pass extra quotes in path with spaces.
    • Added unit test Ensure executeUsingExtension does not pass extra quotes in path with spaces for dedicated terminal.

Verification

  • npx tsc -p ./ passed with 0 errors.
  • npx mocha -r out/test/unittests.js --ui tdd out/test/terminals/codeExecution/codeExecutionManager.unit.test.js passed all 12 tests.
  • npx eslint src/client/terminals/codeExecution/codeExecutionManager.ts src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts passed with 0 errors and 0 warnings.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 19:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run Python File passes literal quotes in script path to terminal

2 participants