Repository navigation
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
Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.runInTerminalorextapi.runInDedicatedTerminal),PythonTerminalExecutionOptions.argsexpects raw arguments and handles necessary shell quoting internally.Previously,
executeUsingExtensioninsrc/client/terminals/codeExecution/codeExecutionManager.tsappendedfileToExecute.fsPath.fileToCommandArgumentForPythonExt()tototalArgs. For script paths containing spaces (e.g./path with spaces/main.py),fileToCommandArgumentForPythonExt()wrapped the path in literal quotes ("..."). When passed torunInTerminal, the terminal received literal quotes as part of the path, causing Python to fail with[Errno 2] No such file or directoryor[Errno 22] Invalid argument: '"/path with spaces/main.py"'.Changes
src/client/terminals/codeExecution/codeExecutionManager.ts:fileToExecute.fsPathintotalArgsinstead of wrapping withfileToCommandArgumentForPythonExt(), letting the terminal execution API handle argument quoting.src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts:Ensure executeUsingExtension does not pass extra quotes in path with spaces.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.jspassed all 12 tests.npx eslint src/client/terminals/codeExecution/codeExecutionManager.ts src/test/terminals/codeExecution/codeExecutionManager.unit.test.tspassed with 0 errors and 0 warnings.