gh-148615: Handle -- end-of-options separator in pdb argument parsing#148624
gh-148615: Handle -- end-of-options separator in pdb argument parsing#148624Shrey-N wants to merge 9 commits intopython:mainfrom
-- end-of-options separator in pdb argument parsing#148624Conversation
|
Thanks for fixing this. We need some regression test on this. We need to test the specific case reported, and also some others. I wonder if For the code itself, let's move |
|
Thank you, that makes sense, I will update the PR asap! :) |
|
Hiya @gaogaotiantian, is there anything else needed from my side to move this forward? |
|
Sorry I was kind of busy recently and did not get a chance to take a look :) I don't think this issue worth a while new test class for it. Some test cases in a test method would do. The new test class does not cover anything that the integration test can't cover. Let's just put all the interesting test cases in the same method. It's a relatively corner case and we don't need to overreact. |
The switch from
getopttoargparsein gh-125115,python -m pdbrejects the standard--end-of-options separator. Makes it impossible to pass arguments that share names with pdb flags (like-c) to the target script.The root cause is that pdb's argparse parser has no positional arguments defined, so
parse_known_args()does not consume--and returns it in the remainder list. The manual post processing logic inparse_args()then incorrectly treats it as an unrecognized flag since it starts with-.This adds a check for
--in theelif args[0].startswith('-'). When found, the separator is consumed and parsing continues to the script name. If no script follows, an error is raised. All other unrecognized flags continue to produce the existing error message.Closes gh-148615 :)