microsoft / microsoft/vscode-python-debugger
PowerShell script debugpy.ps1 incorrectly handles multiple arguments passed as an array
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- TypeScript
- Estrelas
- 180
- Forks
- 126
- Merge médio
- 2d 3h
- PRs com merge (30d)
- 3
Descrição
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
}
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece no wrapper debugpy.ps1, concentrando-se em como a lista de argumentos dele é passada para o comando Python em cada branch do OS. Reproduza o problema com os scripts fornecidos run.ps1 e test.py e, em seguida, verifique se os argumentos de array permanecem separados e produzem a saída esperada de sys.argv.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- powershell, python
- Domínio
- cli
- Tipo de issue
- Bug
- Dificuldade
- 1/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Ativa
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 88/100