Skip to content

Commit 299692a

Browse files
authored
gh-88279: Deprecate PySys_SetArgvEx() (#92363)
Deprecate the following C functions: * PySys_SetArgv() * PySys_SetArgvEx() * PySys_SetPath()
1 parent 5f29268 commit 299692a

File tree

6 files changed

+32
-9
lines changed

6 files changed

+32
-9
lines changed

Doc/c-api/init.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,11 @@ Process-wide parameters
616616
single: Py_FatalError()
617617
single: argv (in module sys)
618618
619+
This API is kept for backward compatibility: setting
620+
:c:member:`PyConfig.argv`, :c:member:`PyConfig.parse_argv` and
621+
:c:member:`PyConfig.safe_path` should be used instead, see :ref:`Python
622+
Initialization Configuration <init-config>`.
623+
619624
Set :data:`sys.argv` based on *argc* and *argv*. These parameters are
620625
similar to those passed to the program's :c:func:`main` function with the
621626
difference that the first entry should refer to the script file to be
@@ -659,9 +664,15 @@ Process-wide parameters
659664
.. XXX impl. doesn't seem consistent in allowing ``0``/``NULL`` for the params;
660665
check w/ Guido.
661666
667+
.. deprecated:: 3.11
668+
662669

663670
.. c:function:: void PySys_SetArgv(int argc, wchar_t **argv)
664671
672+
This API is kept for backward compatibility: setting
673+
:c:member:`PyConfig.argv` and :c:member:`PyConfig.parse_argv` should be used
674+
instead, see :ref:`Python Initialization Configuration <init-config>`.
675+
665676
This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set
666677
to ``1`` unless the :program:`python` interpreter was started with the
667678
:option:`-I`.
@@ -674,6 +685,8 @@ Process-wide parameters
674685
675686
.. versionchanged:: 3.4 The *updatepath* value depends on :option:`-I`.
676687
688+
.. deprecated:: 3.11
689+
677690
678691
.. c:function:: void Py_SetPythonHome(const wchar_t *home)
679692

Doc/c-api/intro.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -709,12 +709,10 @@ the table of loaded modules, and creates the fundamental modules
709709
:mod:`builtins`, :mod:`__main__`, and :mod:`sys`. It also
710710
initializes the module search path (``sys.path``).
711711

712-
.. index:: single: PySys_SetArgvEx()
713-
714712
:c:func:`Py_Initialize` does not set the "script argument list" (``sys.argv``).
715-
If this variable is needed by Python code that will be executed later, it must
716-
be set explicitly with a call to ``PySys_SetArgvEx(argc, argv, updatepath)``
717-
after the call to :c:func:`Py_Initialize`.
713+
If this variable is needed by Python code that will be executed later, setting
714+
:c:member:`PyConfig.argv` and :c:member:`PyConfig.parse_argv` must be set: see
715+
:ref:`Python Initialization Configuration <init-config>`.
718716

719717
On most systems (in particular, on Unix and Windows, although the details are
720718
slightly different), :c:func:`Py_Initialize` calculates the module search path

Doc/c-api/sys.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,17 @@ accessible to C code. They all work with the current interpreter thread's
264264
265265
.. c:function:: void PySys_SetPath(const wchar_t *path)
266266
267+
This API is kept for backward compatibility: setting
268+
:c:member:`PyConfig.module_search_paths` and
269+
:c:member:`PyConfig.module_search_paths_set` should be used instead, see
270+
:ref:`Python Initialization Configuration <init-config>`.
271+
267272
Set :data:`sys.path` to a list object of paths found in *path* which should
268273
be a list of paths separated with the platform's search path delimiter
269274
(``:`` on Unix, ``;`` on Windows).
270275
276+
.. deprecated:: 3.11
277+
271278
.. c:function:: void PySys_WriteStdout(const char *format, ...)
272279
273280
Write the output string described by *format* to :data:`sys.stdout`. No

Doc/whatsnew/3.11.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,9 @@ Deprecated
17421742
* :c:func:`PySys_AddWarnOption`
17431743
* :c:func:`PySys_AddXOption`
17441744
* :c:func:`PySys_HasWarnOptions`
1745+
* :c:func:`PySys_SetArgvEx`
1746+
* :c:func:`PySys_SetArgv`
1747+
* :c:func:`PySys_SetPath`
17451748
* :c:func:`Py_SetPath`
17461749
* :c:func:`Py_SetProgramName`
17471750
* :c:func:`Py_SetPythonHome`
@@ -1750,7 +1753,7 @@ Deprecated
17501753

17511754
Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization Configuration
17521755
<init-config>` instead (:pep:`587`).
1753-
(Contributed by Victor Stinner in :issue:`44113`.)
1756+
(Contributed by Victor Stinner in :gh:`88279`.)
17541757

17551758
* Deprecate the ``ob_shash`` member of the :c:type:`PyBytesObject`. Use :c:func:`PyObject_Hash` instead.
17561759
(Contributed by Inada Naoki in :issue:`46864`.)

Include/sysmodule.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ extern "C" {
1010
PyAPI_FUNC(PyObject *) PySys_GetObject(const char *);
1111
PyAPI_FUNC(int) PySys_SetObject(const char *, PyObject *);
1212

13-
PyAPI_FUNC(void) PySys_SetArgv(int, wchar_t **);
14-
PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int);
15-
PyAPI_FUNC(void) PySys_SetPath(const wchar_t *);
13+
Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetArgv(int, wchar_t **);
14+
Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int);
15+
Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetPath(const wchar_t *);
1616

1717
PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
1818
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Deprecate the C functions: :c:func:`PySys_SetArgv`,
2+
:c:func:`PySys_SetArgvEx`, :c:func:`PySys_SetPath`. Patch by Victor Stinner.

0 commit comments

Comments
 (0)