microsoft / microsoft/vscode-python-debugger
PowerShell script debugpy.ps1 incorrectly handles multiple arguments passed as an array
還沒有人認領這個 Issue。
- 主要語言
- TypeScript
- 星號
- 180
- 分支
- 126
- 平均合併
- 2 天 3 小時
- 30 天內合併 PR
- 3
描述
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
}
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 debugpy.ps1 wrapper 開始,著重了解其引數列表在每個 OS 分支中如何傳遞給 Python 命令。使用提供的 run.ps1 和 test.py 指令碼重現問題,然後確認陣列引數仍保持分開,並產生預期的 sys.argv 輸出。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- powershell, python
- 領域
- cli
- Issue 類型
- 缺陷
- 難度
- 1/5
- 預估耗時
- 1-3 小時
- 活躍度
- 活躍
- 描述清晰度
- 描述清楚
- 新手友好度
- 88/100