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
getopt should not accept no_argument that ends with '=' #48879
Comments
Consider the following program tmp.py: import sys, getopt
print(getopt.getopt(sys.argv[1:], '', ['help'])) The program accept "--help" without a value: python helloworld.py --help But if someone invoke the program like: python helloworld.py --help= Python should raise an error. "--help=" is not considered as no_argument in libc's getopt implementation (tested on Mac OS X #include <getopt.h>
static struct option longopts[] = {
{ "help", no_argument, NULL, "h" },
};
#include <getopt.h>
static struct option longopts[] = {
{ "help", no_argument, NULL, 'h' },
};
int main(int argc, char **argv)
{
while (getopt_long(argc, argv, "h", longopts, NULL) != -1);
return 0;
} macbook: |
Can you please also write a regression test in |
Updated patch with a regression test. |
The patch is good. |
I'm not sure why this is still open, would somebody like to comment, see also bpo-4650. |
msg84276 "the patch is good". What is the problem with committing this? |
Fixed in 3.2 (r83116), 2.7 (r83117), 3.1 (r83118) and 2.6 (r83119). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: