diff --git a/Misc/NEWS b/Misc/NEWS index 878305d7f47..4319351dee3 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 3? Core and builtins ----------------- +- Patch #2617: Reserved -J and -X arguments for Jython, IronPython and other + implementations of Python. + Extensions Modules ------------------ diff --git a/Modules/main.c b/Modules/main.c index a9197401254..8e02fe4f46f 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -40,7 +40,7 @@ static char **orig_argv; static int orig_argc; /* command line options */ -#define BASE_OPTS "3bBc:dEhim:OQ:StuUvVW:xX?" +#define BASE_OPTS "3bBc:dEhiJm:OQ:StuUvVW:xX?" #ifndef RISCOS #define PROGRAM_OPTS BASE_OPTS @@ -349,6 +349,8 @@ Py_Main(int argc, char **argv) Py_InteractiveFlag++; break; + /* case 'J': reserved for Jython */ + case 'O': Py_OptimizeFlag++; break; @@ -388,6 +390,8 @@ Py_Main(int argc, char **argv) skipfirstline = 1; break; + /* case 'X': reserved for non-standard arguments */ + case 'U': Py_UnicodeFlag++; break; diff --git a/Python/getopt.c b/Python/getopt.c index 659efcfff81..acdd5d778b7 100644 --- a/Python/getopt.c +++ b/Python/getopt.c @@ -80,7 +80,18 @@ int _PyOS_GetOpt(int argc, char **argv, char *optstring) if ( (option = *opt_ptr++) == '\0') return -1; - + + if (option == 'J') { + fprintf(stderr, "-J is reserved for Jython\n"); + return '_'; + } + + if (option == 'X') { + fprintf(stderr, + "-X is reserved for non-standard arguments\n"); + return '_'; + } + if ((ptr = strchr(optstring, option)) == NULL) { if (_PyOS_opterr) fprintf(stderr, "Unknown option: -%c\n", option);