Skip the value of an overridden DEBUGPY_EXTRA_ARGV switch - #2077
Conversation
When a switch in DEBUGPY_EXTRA_ARGV was already given on the command line, parse_args_helper() skips the switch but not its value. The value is then parsed as the next argument, and a bare value is taken as a positional file target. For example, `--connect 8888 -m spam` with DEBUGPY_EXTRA_ARGV set to `--connect 5678` ends up with target_kind "file" and target "5678" instead of the "spam" module. Consume the value too when skipping a switch that takes one.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR. |
|
Result: Verification detailsVerification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified. Summary: The new module-target regression test passed. The complete CLI test file then passed with **95 tests** using the source tree via `PYTHONPATH=src`. The initial invocation could not collect because debugpy was not installed, and offline editable installation was blocked by a missing `wheel` package. Relevant behavioral coverage passed, but the unavailable standard installation path makes this partially verified. Test runs: 2 passed, 1 not run
|
Rich Chiodo (rchiodo)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
When a switch in
DEBUGPY_EXTRA_ARGVwas already given on the command line,parse_args_helper()skips the switch so that the command line takes precedence (as intended in #1624), but it does not skip the switch's value. That value is then parsed as the next argument, and a bare value is taken as a positional file target.Repro:
--connect 5678is skipped, but5678is then parsed as a file target, so the options end up withtarget_kind == "file"andtarget == "5678"instead of thespammodule. With a positional file target on the command line the stray value happens to be skipped as a duplicate target, which is whytest_override_environment_switchpasses today.The fix consumes the value too when skipping a switch that takes one. Switches without a value and the positional target are unchanged.
Testing:
test_override_environment_switch_with_module_targettotests/debugpy/server/test_cli.py. It fails on main (assert 'file' == 'module') and passes with the fix.tests/debugpy/server/test_cli.py: 95 passed on Windows, Python 3.12.