◐ Shell
clean mode source ↗

gh-133644: Remove `PySys_SetArgv*` for 3.15 by xuantengh · Pull Request #136277 · python/cpython

Expand Up @@ -658,85 +658,6 @@ Process-wide parameters ``sys.version``.

.. c:function:: void PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
.. index:: single: main() 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 executed rather than the executable hosting the Python interpreter. If there isn't a script that will be run, the first entry in *argv* can be an empty string. If this function fails to initialize :data:`sys.argv`, a fatal condition is signalled using :c:func:`Py_FatalError`.
If *updatepath* is zero, this is all the function does. If *updatepath* is non-zero, the function also modifies :data:`sys.path` according to the following algorithm:
- If the name of an existing script is passed in ``argv[0]``, the absolute path of the directory where the script is located is prepended to :data:`sys.path`. - Otherwise (that is, if *argc* is ``0`` or ``argv[0]`` doesn't point to an existing file name), an empty string is prepended to :data:`sys.path`, which is the same as prepending the current working directory (``"."``).
Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:`wchar_t*` string.
See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv` members of the :ref:`Python Initialization Configuration <init-config>`.
.. note:: It is recommended that applications embedding the Python interpreter for purposes other than executing a single script pass ``0`` as *updatepath*, and update :data:`sys.path` themselves if desired. See :cve:`2008-5983`.
On versions before 3.1.3, you can achieve the same effect by manually popping the first :data:`sys.path` element after having called :c:func:`PySys_SetArgv`, for example using::
PyRun_SimpleString("import sys; sys.path.pop(0)\n");
.. versionadded:: 3.1.3
.. XXX impl. doesn't seem consistent in allowing ``0``/``NULL`` for the params; check w/ Guido.
.. deprecated-removed:: 3.11 3.15

.. 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`.
Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a :c:expr:`wchar_t*` string.
See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv` members of the :ref:`Python Initialization Configuration <init-config>`.
.. versionchanged:: 3.4 The *updatepath* value depends on :option:`-I`.
.. deprecated-removed:: 3.11 3.15

.. c:function:: void Py_SetPythonHome(const wchar_t *home)
This API is kept for backward compatibility: setting Expand Down