PowerShell script debugpy.ps1 incorrectly handles multiple arguments passed as an array
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Start in the debugpy.ps1 wrapper, focusing on how its argument list is passed to the Python command in each OS branch. Reproduce the issue with the provided run.ps1 and test.py scripts, then verify that array arguments remain separate and produce the expected sys.argv output.
Written by the indexing model from the issue text.
Description
Description:
When using the PowerShell wrapper script debugpy.ps1 to debug a Python script that accepts multiple command-line arguments, the arguments are not properly passed through to the Python script when provided as an array.
Steps to Reproduce:
- Create a test Python script (
test.py):
import sys
print(sys.argv)
- Create a PowerShell script (
run.ps1):
$arg_list = @('arg1', 'arg2')
$file = "test.py"
& python $file $arg_list # Works correctly
& debugpy $file $arg_list # Fails - arguments are concatenated
- Run the PowerShell script:
.\run.ps1
Actual Result:
['test.py', 'arg1', 'arg2']
['test.py', 'arg1 arg2']
Expected Result:
['test.py', 'arg1', 'arg2']
['test.py', 'arg1', 'arg2']
Root Cause:
The current debugpy.ps1 script passes $args directly to the Python command without using splatting (@args). When an array is passed to the script, PowerShell's $args receives it as a single object rather than expanding it into multiple arguments.
Current code:
if ($os -eq [System.PlatformID]::Win32NT) {
python $env:BUNDLED_DEBUGPY_PATH --listen 0 --wait-for-client $args
} else {
python3 $env:BUNDLED_DEBUGPY_PATH --listen 0 --wait-for-client $args
}
Proposed Fix:
Use the splatting operator (@args) instead of $args to properly expand array arguments:
if ($os -eq [System.PlatformID]::Win32NT) {
python $env:BUNDLED_DEBUGPY_PATH --listen 0 --wait-for-client @args
} else {
python3 $env:BUNDLED_DEBUGPY_PATH --listen 0 --wait-for-client @args
}
- Dominant language
- TypeScript
- Stars
- 181
- Forks
- 126
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/vscode-python-debugger
-
triage-needed
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/vscode-python-debugger#1110 ·
-
triage-needed
microsoft/vscode-python-debugger#1111 · 1 reaction · 1 assignee ·
-
triage-needed
microsoft/vscode-python-debugger#1106 · 1 reaction · 2 assignees ·
-
triage-needed
microsoft/vscode-python-debugger#1104 · 1 reaction · 1 assignee ·
-
triage-needed
Difficulty 4/5 3-5 days Newbie friendliness 58/100
microsoft/vscode-python-debugger#1095 · 1 comment · 1 reaction ·
All issues in microsoft/vscode-python-debugger
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100