]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-133336: Remove reserved ``-J`` flag for Jython (#133444)
authorAdam Turner <9087854+AA-Turner@users.noreply.github.com>
Mon, 5 May 2025 15:09:19 +0000 (16:09 +0100)
committerGitHub <noreply@github.com>
Mon, 5 May 2025 15:09:19 +0000 (15:09 +0000)
Doc/using/cmdline.rst
Doc/whatsnew/2.6.rst
Doc/whatsnew/3.14.rst
Misc/NEWS.d/next/Core_and_Builtins/2025-05-05-15-33-35.gh-issue-133336.miffFi.rst [new file with mode: 0644]
Python/getopt.c

index fa7c9cddf9c6d6d63bb862e2e9c45a8f061ca7b0..a4889cfc36440fa5e5286989cfd0e81a88c5d0a0 100644 (file)
@@ -670,6 +670,13 @@ Miscellaneous options
    .. versionchanged:: 3.10
       Removed the ``-X oldparser`` option.
 
+.. versionremoved:: next
+
+   :option:`!-J` is no longer reserved for use by Jython_,
+   and now has no special meaning.
+
+   .. _Jython: https://www.jython.org/
+
 .. _using-on-controlling-color:
 
 Controlling color
@@ -694,15 +701,6 @@ output. To control the color output only in the Python interpreter, the
 precedence over ``NO_COLOR``, which in turn takes precedence over
 ``FORCE_COLOR``.
 
-Options you shouldn't use
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-.. option:: -J
-
-   Reserved for use by Jython_.
-
-.. _Jython: https://www.jython.org/
-
 
 .. _using-on-envvars:
 
index fdccfb7deb1ed7a28f6d7e44446416b1a0b144b0..9dbc07a34e20a1d38d6a1cf14d94a0fe7c767502 100644 (file)
@@ -1747,7 +1747,7 @@ Interpreter Changes
 -------------------------------
 
 Two command-line options have been reserved for use by other Python
-implementations.  The :option:`-J` switch has been reserved for use by
+implementations.  The :option:`!-J` switch has been reserved for use by
 Jython for Jython-specific options, such as switches that are passed to
 the underlying JVM.  :option:`-X` has been reserved for options
 specific to a particular implementation of Python such as CPython,
index d75ba9ab97373c6b2551d058f80715590c75c52e..f09e517d4569c5885f766ce6a27fafdcc748a79f 100644 (file)
@@ -805,6 +805,11 @@ Other language changes
   :keyword:`async with`).
   (Contributed by Bénédikt Tran in :gh:`128398`.)
 
+* :option:`!-J` is no longer a reserved flag for Jython_,
+  and now has no special meaning.
+  (Contributed by Adam Turner in :gh:`133336`.)
+
+  .. _Jython: https://www.jython.org/
 
 .. _whatsnew314-pep765:
 
diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-05-05-15-33-35.gh-issue-133336.miffFi.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-05-05-15-33-35.gh-issue-133336.miffFi.rst
new file mode 100644 (file)
index 0000000..8516582
--- /dev/null
@@ -0,0 +1,2 @@
+:option:`!-J` is no longer reserved for use by Jython.
+Patch by Adam Turner.
index 39a6938dec7663b02ae4f264879553e8c470fc3b..79bea2359ffffcff4486835f6c54aa3e9211ff3a 100644 (file)
@@ -37,7 +37,7 @@ static const wchar_t *opt_ptr = L"";
 
 /* Python command line short and long options */
 
-#define SHORT_OPTS L"bBc:dEhiIJm:OPqRsStuvVW:xX:?"
+#define SHORT_OPTS L"bBc:dEhiIm:OPqRsStuvVW:xX:?"
 
 static const _PyOS_LongOption longopts[] = {
     /* name, has_arg, val (used in switch in initconfig.c) */
@@ -133,13 +133,6 @@ int _PyOS_GetOpt(Py_ssize_t argc, wchar_t * const *argv, int *longindex)
         return opt->val;
     }
 
-    if (option == 'J') {
-        if (_PyOS_opterr) {
-            fprintf(stderr, "-J is reserved for Jython\n");
-        }
-        return '_';
-    }
-
     if ((ptr = wcschr(SHORT_OPTS, option)) == NULL) {
         if (_PyOS_opterr) {
             fprintf(stderr, "Unknown option: -%c\n", (char)option);