-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
argparse nargs=-1 fails on python 3.12.7 #126708
Comments
Just to confirm my understanding, is there any difference between Looking at the "in the wild" usages in the link you shared, these seem to be predominantly examples of |
In never was intended to support negative If you search non-hackish solution, use Thanks @brianschubert for pointing that such pattern is very rarely used with |
Hi all, I am the maintainer of the linked repo and the author of the original offending code. I hadn't had a chance to review the Github search results for the Thanks to @serhiy-storchaka for suggestions for how to handle the intended use case in a more supported fashion and sorry to waste everyone's time. I think (if @ikappaki agrees) we can just close this ticket. |
Hi all, thank you for looking into this. I think this ticket has served its purpose and can be closed. It can still be used as a reference in case someone falls for the same. Apologies for the shallow impact analysis with |
Bug report
Bug description:
It seems there's a pattern in the wild with
argparse
wherenargs=-1
is used to capture the remaining command line arguments. However, I couldn’t find anything in the argparse nargs documentation to indicate that this is a supported feature, though it appears to be widely used: https://grep.app/search?current=4&q=nargs%3D-1&filter[lang][0]=PythonThis pattern has stopped working as of Python
v3.12.7
, likely due to #124631 which doesn't appear to have made it to v3.13.0, but it has been backported to the3.13
branch.To reproduce,
issue.py
filethe following arguments are required
error.The same works with any other version at the momenet, for example 3.11 or 3.13:
Could you please take a look and advise whether this is something you might want to continue supporting, or if there are alternative approaches you would recommend?
I don't personally use this pattern, but I came across it and thought it would be helpful to report, as it might assist developers in making informed decisions about it.
Thanks
CPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
Windows
The text was updated successfully, but these errors were encountered: