[New-bugs-announce] [issue4629] getopt should not accept no_argument that ends with '='
Wang Chun
report at bugs.python.org
Thu Dec 11 07:54:18 CET 2008
New submission from Wang Chun <yaohua2000 at gmail.com>:
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
Leopard):
#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:~/tmp$ gcc -o tmp tmp.c
macbook:~/tmp$ ./tmp --help=
tmp: option `--help' doesn't allow an argument
macbook:~/tmp$
----------
components: Library (Lib)
messages: 77597
nosy: wangchun
severity: normal
status: open
title: getopt should not accept no_argument that ends with '='
type: behavior
versions: Python 2.1.1, Python 2.1.2, Python 2.2, Python 2.2.1, Python 2.2.2, Python 2.2.3, Python 2.3, Python 2.4, Python 2.5, Python 2.5.3, Python 2.6, Python 2.7, Python 3.0, Python 3.1
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4629>
_______________________________________
More information about the New-bugs-announce
mailing list