]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-88279: Deprecate PySys_SetArgvEx() (#92363)
authorVictor Stinner <vstinner@python.org>
Fri, 6 May 2022 03:24:29 +0000 (05:24 +0200)
committerGitHub <noreply@github.com>
Fri, 6 May 2022 03:24:29 +0000 (05:24 +0200)
Deprecate the following C functions:

* PySys_SetArgv()
* PySys_SetArgvEx()
* PySys_SetPath()

Doc/c-api/init.rst
Doc/c-api/intro.rst
Doc/c-api/sys.rst
Doc/whatsnew/3.11.rst
Include/sysmodule.h
Misc/NEWS.d/next/C API/2022-05-06-04-55-17.gh-issue-88279.3mQ54t.rst [new file with mode: 0644]

index c17379c52ab706e24b6414a64c20d917689637d5..d4954958f855f52895e2b31f9706613412fc0ff4 100644 (file)
@@ -616,6 +616,11 @@ Process-wide parameters
       single: Py_FatalError()
       single: argv (in module sys)
 
+   This API is kept for backward compatibility: setting
+   :c:member:`PyConfig.argv`, :c:member:`PyConfig.parse_argv` and
+   :c:member:`PyConfig.safe_path` should be used instead, see :ref:`Python
+   Initialization Configuration <init-config>`.
+
    Set :data:`sys.argv` based on *argc* and *argv*.  These parameters are
    similar to those passed to the program's :c:func:`main` function with the
    difference that the first entry should refer to the script file to be
@@ -659,9 +664,15 @@ Process-wide parameters
    .. XXX impl. doesn't seem consistent in allowing ``0``/``NULL`` for the params;
       check w/ Guido.
 
+   .. deprecated:: 3.11
+
 
 .. c:function:: void PySys_SetArgv(int argc, wchar_t **argv)
 
+   This API is kept for backward compatibility: setting
+   :c:member:`PyConfig.argv` and :c:member:`PyConfig.parse_argv` should be used
+   instead, see :ref:`Python Initialization Configuration <init-config>`.
+
    This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set
    to ``1`` unless the :program:`python` interpreter was started with the
    :option:`-I`.
@@ -674,6 +685,8 @@ Process-wide parameters
 
    .. versionchanged:: 3.4 The *updatepath* value depends on :option:`-I`.
 
+   .. deprecated:: 3.11
+
 
 .. c:function:: void Py_SetPythonHome(const wchar_t *home)
 
index 3e7890cb7664710dfc02704e54200b7f3e8f53dc..9efac0b83d024d501ece3b21ced6d4587798b814 100644 (file)
@@ -709,12 +709,10 @@ the table of loaded modules, and creates the fundamental modules
 :mod:`builtins`, :mod:`__main__`, and :mod:`sys`.  It also
 initializes the module search path (``sys.path``).
 
-.. index:: single: PySys_SetArgvEx()
-
 :c:func:`Py_Initialize` does not set the "script argument list"  (``sys.argv``).
-If this variable is needed by Python code that will be executed later, it must
-be set explicitly with a call to  ``PySys_SetArgvEx(argc, argv, updatepath)``
-after the call to :c:func:`Py_Initialize`.
+If this variable is needed by Python code that will be executed later, setting
+:c:member:`PyConfig.argv` and :c:member:`PyConfig.parse_argv` must be set: see
+:ref:`Python Initialization Configuration <init-config>`.
 
 On most systems (in particular, on Unix and Windows, although the details are
 slightly different), :c:func:`Py_Initialize` calculates the module search path
index 66216eee6d06ed6f845e4e7140f479ff1880ef27..5e8d993100f6323f9ce68a3e4552a499b40d4a25 100644 (file)
@@ -264,10 +264,17 @@ accessible to C code.  They all work with the current interpreter thread's
 
 .. c:function:: void PySys_SetPath(const wchar_t *path)
 
+   This API is kept for backward compatibility: setting
+   :c:member:`PyConfig.module_search_paths` and
+   :c:member:`PyConfig.module_search_paths_set` should be used instead, see
+   :ref:`Python Initialization Configuration <init-config>`.
+
    Set :data:`sys.path` to a list object of paths found in *path* which should
    be a list of paths separated with the platform's search path delimiter
    (``:`` on Unix, ``;`` on Windows).
 
+   .. deprecated:: 3.11
+
 .. c:function:: void PySys_WriteStdout(const char *format, ...)
 
    Write the output string described by *format* to :data:`sys.stdout`.  No
index c84b36f8d6c403373dee0683dbcafeadb1efa880..822cb8b1f0f343cecd24b6dc2179f5214035f00a 100644 (file)
@@ -1742,6 +1742,9 @@ Deprecated
   * :c:func:`PySys_AddWarnOption`
   * :c:func:`PySys_AddXOption`
   * :c:func:`PySys_HasWarnOptions`
+  * :c:func:`PySys_SetArgvEx`
+  * :c:func:`PySys_SetArgv`
+  * :c:func:`PySys_SetPath`
   * :c:func:`Py_SetPath`
   * :c:func:`Py_SetProgramName`
   * :c:func:`Py_SetPythonHome`
@@ -1750,7 +1753,7 @@ Deprecated
 
   Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization Configuration
   <init-config>` instead (:pep:`587`).
-  (Contributed by Victor Stinner in :issue:`44113`.)
+  (Contributed by Victor Stinner in :gh:`88279`.)
 
 * Deprecate the ``ob_shash`` member of the :c:type:`PyBytesObject`. Use :c:func:`PyObject_Hash` instead.
   (Contributed by Inada Naoki in :issue:`46864`.)
index 3463c6223090094abf8cc1448b7a1f999f0a537b..b5087119b1cae7d7c9c8becc3327a9a5040a6bc6 100644 (file)
@@ -10,9 +10,9 @@ extern "C" {
 PyAPI_FUNC(PyObject *) PySys_GetObject(const char *);
 PyAPI_FUNC(int) PySys_SetObject(const char *, PyObject *);
 
-PyAPI_FUNC(void) PySys_SetArgv(int, wchar_t **);
-PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int);
-PyAPI_FUNC(void) PySys_SetPath(const wchar_t *);
+Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetArgv(int, wchar_t **);
+Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int);
+Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetPath(const wchar_t *);
 
 PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
                  Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
diff --git a/Misc/NEWS.d/next/C API/2022-05-06-04-55-17.gh-issue-88279.3mQ54t.rst b/Misc/NEWS.d/next/C API/2022-05-06-04-55-17.gh-issue-88279.3mQ54t.rst
new file mode 100644 (file)
index 0000000..eb448f9
--- /dev/null
@@ -0,0 +1,2 @@
+Deprecate the C functions: :c:func:`PySys_SetArgv`,
+:c:func:`PySys_SetArgvEx`, :c:func:`PySys_SetPath`. Patch by Victor Stinner.