microsoft / microsoft/vscode-python-debugger
PowerShell script debugpy.ps1 incorrectly handles multiple arguments passed as an array
还没有人认领这个 Issue。
- 主要语言
- TypeScript
- 星标
- 181
- 派生
- 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