microsoft / microsoft/vscode-python-debugger

PowerShell script debugpy.ps1 incorrectly handles multiple arguments passed as an array

オープン 初心者向け
#1,024 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

triage-needed
主要言語
TypeScript
スター
180
フォーク
126
平均マージ
2日 3時間
マージ済み PR(30日)
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:

  1. Create a test Python script (test.py):
import sys
print(sys.argv)
  1. 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
  1. 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
}

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

debugpy.ps1 ラッパーから始め、各 OS ブランチでその引数リストが Python コマンドにどのように渡されるかに注目してください。提供されている run.ps1 と test.py スクリプトで問題を再現し、その後、配列引数が分離されたままになり、期待される sys.argv の出力が生成されることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
powershell, python
領域
cli
issue の種類
バグ
難易度
1/5
見積もり時間
1〜3時間
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
88/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。