microsoft / microsoft/vscode-python-debugger
PowerShell script debugpy.ps1 incorrectly handles multiple arguments passed as an array
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 180
- Forks
- 126
- Ø Merge
- 2 T. 3 Std.
- Gemergte PRs (30 T.)
- 3
Beschreibung
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
}
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne im debugpy.ps1-Wrapper und konzentriere dich darauf, wie seine Argumentliste in jedem OS-Zweig an den Python-Befehl übergeben wird. Reproduziere das Problem mit den bereitgestellten Skripten run.ps1 und test.py und überprüfe anschließend, dass Array-Argumente getrennt bleiben und die erwartete sys.argv-Ausgabe erzeugen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- powershell, python
- Bereich
- cli
- Issue-Typ
- Bug
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Aktiv
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 88/100