Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The following functions can be safely called before Python is initialized:
* :c:func:`PyObject_SetArenaAllocator`
* :c:func:`Py_SetProgramName`
* :c:func:`Py_SetPythonHome`
* :c:func:`PySys_ResetWarnOptions`
* :c:func:`!PySys_ResetWarnOptions`
* the configuration functions covered in :ref:`init-config`

* Informative functions:
Expand Down
8 changes: 0 additions & 8 deletions Doc/c-api/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,6 @@ accessible to C code. They all work with the current interpreter thread's
case *name* is deleted from the sys module. Returns ``0`` on success, ``-1``
on error.

.. c:function:: void PySys_ResetWarnOptions()

Reset :data:`sys.warnoptions` to an empty list. This function may be
called prior to :c:func:`Py_Initialize`.

.. deprecated-removed:: 3.13 3.15
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.

.. c:function:: void PySys_WriteStdout(const char *format, ...)

Write the output string described by *format* to :data:`sys.stdout`. No
Expand Down
1 change: 0 additions & 1 deletion Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Doc/deprecations/c-api-pending-removal-in-3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Pending removal in Python 3.15
Set :c:member:`PyConfig.program_name` instead.
* :c:func:`!Py_SetPythonHome()`:
Set :c:member:`PyConfig.home` instead.
* :c:func:`PySys_ResetWarnOptions`:
* :c:func:`!PySys_ResetWarnOptions`:
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.

The :c:func:`Py_InitializeFromConfig` API should be used with
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,7 @@ Deprecated C APIs

* Deprecate old Python initialization functions:

* :c:func:`PySys_ResetWarnOptions`:
* :c:func:`!PySys_ResetWarnOptions`:
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
* :c:func:`!Py_GetExecPrefix`:
Get :data:`sys.exec_prefix` instead.
Expand Down
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,11 @@ Removed C APIs
of :c:func:`PyImport_ImportModule`.
(Contributed by Bénédikt Tran in :gh:`133644`.)

* Remove deprecated :c:func:`!PySys_ResetWarnOptions`.
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.

(Contributed by Nikita Sobolev in :gh:`138886`.)

The following functions are removed in favor of :c:func:`PyConfig_Get`.
The |pythoncapi_compat_project| can be used to get :c:func:`!PyConfig_Get`
on Python 3.13 and older.
Expand Down
2 changes: 0 additions & 2 deletions Include/sysmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...)
PyAPI_FUNC(void) PySys_FormatStdout(const char *format, ...);
PyAPI_FUNC(void) PySys_FormatStderr(const char *format, ...);

Py_DEPRECATED(3.13) PyAPI_FUNC(void) PySys_ResetWarnOptions(void);

PyAPI_FUNC(PyObject *) PySys_GetXOptions(void);

#ifdef __cplusplus
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ def test_pre_initialization_sys_options(self):
print(out)
print(err)
expected_output = (
"sys.warnoptions: ['once', 'module', 'default']\n"
"sys.warnoptions: ['default', 'once', 'module']\n"
"sys._xoptions: {'not_an_option': '1', 'also_not_an_option': '2'}\n"
"warnings.filters[:3]: ['default', 'module', 'once']\n"
"warnings.filters[:3]: ['module', 'once', 'default']\n"
)
self.assertIn(expected_output, out)
self.assertEqual(err, '')
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.13.0a1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6592,7 +6592,7 @@ functions, deprecated in Python 3.9. Patch by Victor Stinner.

Deprecate old Python initialization functions:

* :c:func:`PySys_ResetWarnOptions`
* :c:func:`!PySys_ResetWarnOptions`
* :c:func:`!Py_GetExecPrefix`
* :c:func:`!Py_GetPath`
* :c:func:`!Py_GetPrefix`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove deprecated :c:func:`!PySys_ResetWarnOptions` C-API function.
1 change: 1 addition & 0 deletions Misc/stable_abi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@
abi_only = true
[function.PySys_ResetWarnOptions]
added = '3.2'
abi_only = true
[function.PySys_SetArgv]
added = '3.2'
[function.PySys_SetArgvEx]
Expand Down
3 changes: 0 additions & 3 deletions Programs/_testembed.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,9 @@ static int test_pre_initialization_sys_options(void)

_Py_EMBED_PREINIT_CHECK("Checking PySys_AddWarnOption\n");
PySys_AddWarnOption(L"default");
_Py_EMBED_PREINIT_CHECK("Checking PySys_ResetWarnOptions\n");
PySys_ResetWarnOptions();
_Py_EMBED_PREINIT_CHECK("Checking PySys_AddWarnOption linked list\n");
PySys_AddWarnOption(dynamic_once_warnoption);
PySys_AddWarnOption(L"module");
PySys_AddWarnOption(L"default");
_Py_EMBED_PREINIT_CHECK("Checking PySys_AddXOption\n");
PySys_AddXOption(L"not_an_option=1");
PySys_AddXOption(dynamic_xoption);
Expand Down
2 changes: 1 addition & 1 deletion Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3045,7 +3045,7 @@ get_warnoptions(PyThreadState *tstate)
return warnoptions;
}

void
PyAPI_FUNC(void)
PySys_ResetWarnOptions(void)
{
PyThreadState *tstate = _PyThreadState_GET();
Expand Down
Loading