summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-11-18 11:46:38 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-11-18 11:46:38 (GMT)
commitdb5947f0f3a662f1e8e9201295a3f2288b0bbe8c (patch)
treed257618e91ad31bd8bd51e1e629a1cedcb009584 /Python
parent9e94972eede8b2bb9a16f867db3da9892759ac70 (diff)
downloadcpython-db5947f0f3a662f1e8e9201295a3f2288b0bbe8c.zip
cpython-db5947f0f3a662f1e8e9201295a3f2288b0bbe8c.tar.gz
cpython-db5947f0f3a662f1e8e9201295a3f2288b0bbe8c.tar.bz2
#16306: Fix multiple error messages when unknown command line parameters where passed to the interpreter. Patch by Hieu Nguyen.
Diffstat (limited to 'Python')
-rw-r--r--Python/getopt.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/Python/getopt.c b/Python/getopt.c
index e96eb6c..624da9a 100644
--- a/Python/getopt.c
+++ b/Python/getopt.c
@@ -41,7 +41,7 @@ static char *opt_ptr = "";
void _PyOS_ResetGetOpt(void)
{
- _PyOS_opterr = 1;
+ _PyOS_opterr = 0; /* prevent printing the error in 2nd loop in main.c */
_PyOS_optind = 1;
_PyOS_optarg = NULL;
opt_ptr = "";
@@ -86,17 +86,19 @@ int _PyOS_GetOpt(int argc, char **argv, char *optstring)
opt_ptr = &argv[_PyOS_optind++][1];
}
- if ( (option = *opt_ptr++) == '\0')
+ if ((option = *opt_ptr++) == '\0')
return -1;
if (option == 'J') {
- fprintf(stderr, "-J is reserved for Jython\n");
+ if (_PyOS_opterr)
+ fprintf(stderr, "-J is reserved for Jython\n");
return '_';
}
if (option == 'X') {
- fprintf(stderr,
- "-X is reserved for implementation-specific arguments\n");
+ if (_PyOS_opterr)
+ fprintf(stderr,
+ "-X is reserved for implementation-specific arguments\n");
return '_';
}
@@ -117,7 +119,7 @@ int _PyOS_GetOpt(int argc, char **argv, char *optstring)
if (_PyOS_optind >= argc) {
if (_PyOS_opterr)
fprintf(stderr,
- "Argument expected for the -%c option\n", option);
+ "Argument expected for the -%c option\n", option);
return '_';
}