[Python-checkins] r62293 - in python/trunk: Misc/NEWS Modules/main.c Python/getopt.c

christian.heimes python-checkins at python.org
Sat Apr 12 19:24:16 CEST 2008


Author: christian.heimes
Date: Sat Apr 12 15:03:03 2008
New Revision: 62293

Log:
Applied patch #2617 from Frank Wierzbicki wit some extras from me
-J and -X are now reserved for Jython and non-standard arguments (e.g. IronPython). I've added some extra comments to make sure the reservation don't get missed in the future.

Modified:
   python/trunk/Misc/NEWS
   python/trunk/Modules/main.c
   python/trunk/Python/getopt.c

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Sat Apr 12 15:03:03 2008
@@ -12,6 +12,9 @@
 Core and builtins
 -----------------
 
+- Patch #2617: Reserved -J and -X arguments for Jython, IronPython and other
+  implementations of Python. 
+
 Extensions Modules
 ------------------
 

Modified: python/trunk/Modules/main.c
==============================================================================
--- python/trunk/Modules/main.c	(original)
+++ python/trunk/Modules/main.c	Sat Apr 12 15:03:03 2008
@@ -40,7 +40,7 @@
 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_InteractiveFlag++;
 			break;
 
+		/* case 'J': reserved for Jython */
+
 		case 'O':
 			Py_OptimizeFlag++;
 			break;
@@ -388,6 +390,8 @@
 			skipfirstline = 1;
 			break;
 
+		/* case 'X': reserved for non-standard arguments */
+
 		case 'U':
 			Py_UnicodeFlag++;
 			break;

Modified: python/trunk/Python/getopt.c
==============================================================================
--- python/trunk/Python/getopt.c	(original)
+++ python/trunk/Python/getopt.c	Sat Apr 12 15:03:03 2008
@@ -80,7 +80,18 @@
 
 	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);


More information about the Python-checkins mailing list