Repository navigation
Running a file will not correctly escape the filename #25508
Description
Type: Bug
Behaviour
The python extension does not properly escape filenames when passing them as arguments to the python interpreter when you run them. This fails when you use quotes in a filename.
I understand that modules should not have quotes in the name, but there seems to be no such limitation on filenames passed to the python interpreter, so in my opinion this is a bug in the extension. In any case validating the module name should be up to Python, not the extension.
I saw this behaviour both on Mac OS and Windows+WSL.
Steps to reproduce:
Create a filename with quotes in it, e.g. "test".py
Run it using the Python extension.
This will fail:
python: can't open file '/Users/reindert/demo/test.py': [Errno 2] No such file or directoryExtension version: 2025.14.0
VS Code version: Code 1.104.3 (Universal) (385651c938df8a906869babee516bffd0ddb9829, 2025-10-02T12:30:51.747Z)
OS version: Darwin arm64 24.3.0
Modes:
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.6
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): PipEnv
- Value of the
python.languageServersetting: Default
User Settings
languageServer: "Pylance"
Installed Extensions
| Extension Name | Extension Id | Version |
|---|---|---|
| ansible | red | 25.9.0 |
| copilot | Git | 1.372.0 |
| copilot-chat | Git | 0.31.4 |
| debugpy | ms- | 2025.10.0 |
| js-debug | ms- | 1.104.0 |
| js-debug-companion | ms- | 1.1.3 |
| jupyter | ms- | 2025.8.0 |
| jupyter-keymap | ms- | 1.1.2 |
| jupyter-renderers | ms- | 1.3.0 |
| mypy-type-checker | ms- | 2025.2.0 |
| python | ms- | 2025.14.0 |
| ruff | cha | 2025.26.0 |
| vscode-containers | ms- | 2.2.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-pylance | ms- | 2025.8.3 |
| vscode-python-envs | ms- | 1.8.0 |
| vscode-yaml | red | 1.19.0 |
System Info
| Item | Value |
|---|---|
| CPUs | Apple M4 (10 x 2400) |
| GPU Status | 2d_canvas: enabled direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: enabled_on trees_in_viz: disabled_off video_decode: enabled video_encode: enabled webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
| Load (avg) | 3, 2, 2 |
| Memory (System) | 16.00GB (0.06GB free) |
| Process Argv | --crash-reporter-id 92110737-0b4d-4d75-9862-eb1d81e07ab5 |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368cf:30146710
vswsl492:30256859
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
usemplatestapi:31297334
6518g693:31334701
aj953862:31281341
cs4_fixed:31391938
nes-set-on:31351930
testaa123:31335226
6abeh943:31336334
aa_c:31379599
0cj2b977:31352657
gendocstringt:31395207
0574c672:31362109
cloudbuttont:31379625
todos-0:31390406
multireplacestring:31393295
treatment_gpt5applypatchexclusively:31394181
3efgi100_wstrepl:31382709
trigger-command-fix:31379601
auto_model_enabled:31385282
use-responses-api:31390855
bd6f95_c:31397101
Activity
eleanorjboyd commentedon Oct 10, 2025
How exactly are you running your code? Is it via a launch.json or the run button? This impacts which part of the code handles it which is why I am wondering. Thanks!
codesensei-courses commentedon Oct 11, 2025
eleanorjboyd commentedon Oct 13, 2025
Hi can you try again on the most recent pre-release version? There was an issue with path quoting which I have now fixed.
codesensei-courses commentedon Oct 14, 2025
Unfortunately the problem persists.. I have installed the following version of the python extension, let me know if I need to install another version: 2025.17.2025100201
Here's the output from running a file called
"test".py:eleanorjboyd commentedon Dec 17, 2025
temp
eleanorjboyd commentedon Dec 17, 2025
To summarize-
Running Python files with quotes in the filename fails:
File: /path/"test".py
Command sent: python /path/"test".py
Shell strips quotes → looks for /path/test.py → FileNotFoundError
Root Cause
extensions.ts:33-42 checks for spaces, &, () to decide if quoting is needed, but doesn't escape internal quotes.
Anthony Kim (@anthonykim1)
I see that maybe the Shell Integration API handles this for us - is this right and could we move to using shell integration for this if enabled to remove our preemptively escaping?
github-actions commentedon Jan 17, 2026
Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.
Happy Coding!