diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 409539dec17d73..d6ff0337dc7f2c 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -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 `. - - 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 `. - - .. 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 `. - - 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 `. - - .. 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 diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index 144c5608e07426..a9bc284c56dafe 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2242,15 +2242,6 @@ PySys_GetObject:const char*:name:: PySys_GetXOptions:PyObject*::0: -PySys_SetArgv:void::: -PySys_SetArgv:int:argc:: -PySys_SetArgv:wchar_t**:argv:: - -PySys_SetArgvEx:void::: -PySys_SetArgvEx:int:argc:: -PySys_SetArgvEx:wchar_t**:argv:: -PySys_SetArgvEx:int:updatepath:: - PySys_SetObject:int::: PySys_SetObject:const char*:name:: PySys_SetObject:PyObject*:v:+1: diff --git a/Doc/data/stable_abi.dat b/Doc/data/stable_abi.dat index 0d0dfb3843260e..73cb3ba0adfa29 100644 --- a/Doc/data/stable_abi.dat +++ b/Doc/data/stable_abi.dat @@ -635,8 +635,6 @@ func,PySys_GetOptionalAttr,3.15,, func,PySys_GetOptionalAttrString,3.15,, func,PySys_GetXOptions,3.7,, func,PySys_ResetWarnOptions,3.2,, -func,PySys_SetArgv,3.2,, -func,PySys_SetArgvEx,3.2,, func,PySys_SetObject,3.2,, func,PySys_WriteStderr,3.2,, func,PySys_WriteStdout,3.2,, diff --git a/Include/sysmodule.h b/Include/sysmodule.h index 2f362791797ded..35a12650a50017 100644 --- a/Include/sysmodule.h +++ b/Include/sysmodule.h @@ -13,9 +13,6 @@ PyAPI_FUNC(int) PySys_GetOptionalAttrString(const char *, PyObject **); PyAPI_FUNC(PyObject *) PySys_GetObject(const char *); PyAPI_FUNC(int) PySys_SetObject(const char *, PyObject *); -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); - PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) Py_GCC_ATTRIBUTE((format(printf, 1, 2))); PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) diff --git a/Misc/NEWS.d/3.13.0b1.rst b/Misc/NEWS.d/3.13.0b1.rst index 97731276679ba6..2d972cf9883931 100644 --- a/Misc/NEWS.d/3.13.0b1.rst +++ b/Misc/NEWS.d/3.13.0b1.rst @@ -1625,8 +1625,8 @@ Restore functions removed in Python 3.13 alpha 1: * :c:func:`Py_SetPythonHome` * :c:func:`Py_SetProgramName` -* :c:func:`PySys_SetArgvEx` -* :c:func:`PySys_SetArgv` +* :c:func:`!PySys_SetArgvEx` +* :c:func:`!PySys_SetArgv` Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/C_API/2025-07-04-15-44-49.gh-issue-133644.Oao-7A.rst b/Misc/NEWS.d/next/C_API/2025-07-04-15-44-49.gh-issue-133644.Oao-7A.rst new file mode 100644 index 00000000000000..07811dc14bb274 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2025-07-04-15-44-49.gh-issue-133644.Oao-7A.rst @@ -0,0 +1,2 @@ +Remove deprecated function :c:func:`!PySys_SetArgv` and +:c:func:`!PySys_SetArgvEx`. Set :c:member:`PyConfig.argv` instead. diff --git a/Misc/stable_abi.toml b/Misc/stable_abi.toml index 1f323cc03973e5..131181cd118802 100644 --- a/Misc/stable_abi.toml +++ b/Misc/stable_abi.toml @@ -1337,8 +1337,10 @@ added = '3.2' [function.PySys_SetArgv] added = '3.2' + abi_only = true [function.PySys_SetArgvEx] added = '3.2' + abi_only = true [function.PySys_SetObject] added = '3.2' [function.PySys_SetPath] diff --git a/Python/sysmodule.c b/Python/sysmodule.c index ae6cf306735939..b463f650617e4f 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -4235,7 +4235,8 @@ make_sys_argv(int argc, wchar_t * const * argv) return list; } -void +/* removed in 3.15, but kept for stable ABI compatibility */ +PyAPI_FUNC(void) PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath) { wchar_t* empty_argv[1] = {L""}; @@ -4282,7 +4283,8 @@ PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath) } } -void +/* removed in 3.15, but kept for stable ABI compatibility */ +PyAPI_FUNC(void) PySys_SetArgv(int argc, wchar_t **argv) { _Py_COMP_DIAG_PUSH