Skip to content

Fix debugpy.ps1 argument forwarding with splatting (@args) - #1146

Open
TEJA P C (PCTEJA) wants to merge 3 commits into
microsoft:mainfrom
PCTEJA:fix-debugpy-ps1-splatting-1024
Open

TEJA P C (PCTEJA) wants to merge 3 commits into
microsoft:mainfrom
PCTEJA:fix-debugpy-ps1-splatting-1024

Conversation

@PCTEJA

@PCTEJA TEJA P C (PCTEJA) commented Nov 14, 2026 •

Copy link
Copy Markdown

Summary

Fixes #1024.

The PowerShell no-config wrapper bundled/scripts/noConfigScripts/debugpy.ps1 forwarded $args without splatting, so when a caller passed an array of arguments, they reached the Python process concatenated as a single string:

$arg_list = @('arg1', 'arg2')
& debugpy test.py $arg_list   # sys.argv -> ['test.py', 'arg1 arg2']  (wrong)
& python  test.py $arg_list   # sys.argv -> ['test.py', 'arg1', 'arg2'] (correct)

Change

Use splatting (@args) in both invocations in debugpy.ps1 (Windows python branch and non-Windows python3 branch). Two lines changed; nothing else.

Testing

Reproduced and verified with PowerShell 7.4.6 using a stub adapter script that prints sys.argv:

  • Before: ["--listen", "0", "--wait-for-client", "test.py", "arg1 arg2"]
  • After: ["--listen", "0", "--wait-for-client", "test.py", "arg1", "arg2"]
  • Also verified after the fix: single arguments containing spaces ("my script.py", "one arg") remain single arguments, and invoking with no extra arguments works.

I have reviewed every changed line and take responsibility for it.

The PowerShell no-config wrapper forwarded $args without splatting,
so an array of arguments passed by a caller reached the Python
process concatenated as a single string (e.g. 'arg1 arg2' instead of
two separate argv entries).

Use @Args in both the Windows (python) and non-Windows (python3)
invocations so array arguments expand into separate arguments,
matching how the caller could pass them to python directly.

Fixes microsoft#1024
@PCTEJA

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@PCTEJA

Copy link
Copy Markdown
Author

Hi Rich Chiodo (@rchiodo), would you mind reviewing this one when you get a chance? It fixes debugpy.ps1 argument forwarding with splatting (Args). Happy to fix anything you spot.

@rchiodo Rich Chiodo (rchiodo) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can you add a regression test?

@rchiodo Rich Chiodo (rchiodo) added the bug Issue identified by VS Code Team member as probable bug label Nov 17, 2026
@PCTEJA

Copy link
Copy Markdown
Author

Sure, Rich Chiodo (@rchiodo). Thank you for approving.

Run the real wrapper under PowerShell with the bundled debugpy path pointed at a stub that prints sys.argv, called with an array argument. The array must reach the Python process as separate arguments, not one space-joined string.
@PCTEJA

Copy link
Copy Markdown
Author

Rich Chiodo (@rchiodo) could you please approve it again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants