Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#1,024 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
powershell, python
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu trong wrapper debugpy.ps1, tập trung vào cách danh sách đối số của nó được truyền đến lệnh Python trong từng nhánh OS. Tái hiện vấn đề bằng các script run.ps1 và test.py được cung cấp, sau đó xác minh rằng các đối số mảng vẫn tách biệt và tạo ra đầu ra sys.argv như mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

triage-needed

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
}
Ngôn ngữ chính
TypeScript
Star
181
Fork
126
Merge trung bình
2 ngày 3 giờ
Pull request đã merge (30 ngày)
3

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/vscode-python-debugger

Tất cả issue của microsoft/vscode-python-debugger

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.