Issue4629
Created on 2008-12-11 06:54 by wangchun, last changed 2009-03-27 17:04 by amaury.forgeotdarc.
|
msg77597 - (view) |
Author: Wang Chun (wangchun) |
Date: 2008-12-11 06:54 |
|
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$
|
|
msg78283 - (view) |
Author: STINNER Victor (haypo) |
Date: 2008-12-25 23:20 |
|
Can you please also write a regression test in
Lib/test/test_getopt.py?
|
|
msg84247 - (view) |
Author: STINNER Victor (haypo) |
Date: 2009-03-27 01:28 |
|
Updated patch with a regression test.
|
|
msg84276 - (view) |
Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) |
Date: 2009-03-27 17:04 |
|
The patch is good.
|
|
| Date |
User |
Action |
Args |
| 2009-03-27 17:04:10 | amaury.forgeotdarc | set | resolution: accepted
messages:
+ msg84276 nosy:
+ amaury.forgeotdarc |
| 2009-03-27 01:28:56 | haypo | set | files:
+ getopt-2.patch
messages:
+ msg84247 |
| 2008-12-25 23:20:10 | haypo | set | nosy:
+ haypo messages:
+ msg78283 |
| 2008-12-20 14:28:46 | loewis | set | versions:
- Python 2.5, Python 2.4, Python 2.3, Python 2.2.3, Python 2.2.2, Python 2.2.1, Python 2.2, Python 2.1.2, Python 2.1.1, Python 2.5.3 |
| 2008-12-11 07:12:45 | wangchun | set | files:
+ getopt.py.diff keywords:
+ patch |
| 2008-12-11 06:54:17 | wangchun | create | |
|