Skip to content

Fix Run Python File paths with spaces when using Python Environments - #26275

Merged
Eduardo Villalpando Mello (edvilme) merged 4 commits into
microsoft:mainfrom
BeniNobel:fix/run-python-file-double-quoting
Nov 16, 2026
Merged

Eduardo Villalpando Mello (edvilme) merged 4 commits into
microsoft:mainfrom
BeniNobel:fix/run-python-file-double-quoting

Conversation

@BeniNobel

Copy link
Copy Markdown

Fixes #26274

Summary

Pass the script path as a raw argument to the Python Environments terminal API. The previous path helper added shell quotes before calling an API that handles arguments itself, so those quotes became part of the filename. Windows slash normalization is preserved.

Testing

  • npx gulp prePublishNonBundle
  • npm run checkDependencies
  • npm run lint
  • npm run format-check
  • git diff --check
  • Terminal unit tests: 107 passed, including the new regression test for all three Run Python File command variants and paths with spaces, quotes, apostrophes, and shell metacharacters.
  • Full TypeScript unit suite on Node 22: 5,276 passed, 36 Windows-only tests pending, and 2 failures in the unrelated macOS locator test file. Excluding that file: 5,275 passed, 36 pending, 0 failures.
  • VS Code extension-host verification with Python Environments 1.42.0: 3/3 scripts passed with shell integration enabled and 3/3 with it disabled. The installed unpatched Python extension failed all three corresponding checks.
  • Clicked the top-right Run Python File button in an isolated VS Code instance with the patched extension; a script in a path containing spaces ran successfully.

Review notes

The change affects only the Python Environments terminal path. Python Environments 1.40.0 still fails for some filenames containing shell metacharacters; this PR does not change that version's handling. The 36 pending unit tests are Windows-only and were not run on macOS.

Suggested impact label: bug.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 09:23

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.

@BeniNobel

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@edvilme

Copy link
Copy Markdown

Hello Beni Inganji (@BeniNobel)
Thank you for working on this. This PR is superseeded by #26276. However, the broad test coverage can be useful for us. I will let it run to see if we find anything useful. Thank you!

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.

🟡 Changes recommended

The new test incorrectly expects forward slashes instead of file.fsPath, causing it to fail on Windows despite correct raw-path behavior.

1 open issue

Review effort: Balanced

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@edvilme
Eduardo Villalpando Mello (edvilme) merged commit dc54b81 into microsoft:main Nov 16, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debt Code quality issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run Python File passes literal quotes in script path to terminal

5 participants