]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-138886: Remove deprecated `PySys_ResetWarnOptions` C-API function (#138887)
authorsobolevn <mail@sobolevn.me>
Mon, 15 Sep 2025 09:01:33 +0000 (12:01 +0300)
committerGitHub <noreply@github.com>
Mon, 15 Sep 2025 09:01:33 +0000 (12:01 +0300)
12 files changed:
Doc/c-api/init.rst
Doc/c-api/sys.rst
Doc/data/stable_abi.dat
Doc/deprecations/c-api-pending-removal-in-3.15.rst
Doc/whatsnew/3.13.rst
Doc/whatsnew/3.15.rst
Include/sysmodule.h
Misc/NEWS.d/3.13.0a1.rst
Misc/NEWS.d/next/C_API/2025-09-14-13-09-47.gh-issue-138886.dlcTXL.rst [new file with mode: 0644]
Misc/stable_abi.toml
Programs/_testembed.c
Python/sysmodule.c

index bb9e08acee14c2cb375e9d6f70a7555ec27d909d..379330f380400f91031e90fb6e25b72e4813eead 100644 (file)
@@ -41,7 +41,6 @@ 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`
   * the configuration functions covered in :ref:`init-config`
 
 * Informative functions:
index b34936dd55e94ca9a6932ba9277b291e5e643f9d..9a5e26d231cc0c85b8f8d57df2e24445e773ef36 100644 (file)
@@ -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
index 641f7bb380447158b961cafe9d8e7139ef5d1727..3f51254494c654edade8f7a80ec809383f7af04d 100644 (file)
@@ -637,7 +637,6 @@ func,PySys_GetObject,3.2,,
 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,,
index a3e335ecaf432446a43ed950c9331b336a70cb89..8db3631cab31f1f6f01c0072028e2d9619503089 100644 (file)
@@ -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
index 6545da66afc4fce4313fc2dfde5ac34a7b049970..67fec4ebc4a234271d5f6cdec5bbcb28ce4d9807 100644 (file)
@@ -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.
index 9031301989e39617eb70fb4bb34823d242dd3d93..ed44558c1d3beb4ed7522dddf4964dcaf8b5dc64 100644 (file)
@@ -815,6 +815,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.
index 2f362791797ded62948b707190a66162908e7906..b7d800c5e5db0b97dcefb7924880bc904b585025 100644 (file)
@@ -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
index 0741eab4eca6a46b67bd5d398fda303ccd3be14f..a3aa7353a1bba15b76c403603e58f692f1c1f1d5 100644 (file)
@@ -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`
diff --git a/Misc/NEWS.d/next/C_API/2025-09-14-13-09-47.gh-issue-138886.dlcTXL.rst b/Misc/NEWS.d/next/C_API/2025-09-14-13-09-47.gh-issue-138886.dlcTXL.rst
new file mode 100644 (file)
index 0000000..a77f429
--- /dev/null
@@ -0,0 +1 @@
+Remove deprecated :c:func:`!PySys_ResetWarnOptions` C-API function.
index bc0fab4852811510eabe6b09df83ec38d2cb1ffd..d651e0fac111b169d6ff9c619f3f9c682420bb5c 100644 (file)
     abi_only = true
 [function.PySys_ResetWarnOptions]
     added = '3.2'
+    abi_only = true
 [function.PySys_SetArgv]
     added = '3.2'
 [function.PySys_SetArgvEx]
index 28c004c3c5ac2c685f73ed1a7c2ef428fabeef0a..4f5a14b8ca6c80b9eb1b4a7deeff45121bec33ef 100644 (file)
@@ -22,6 +22,10 @@ extern void PySys_AddWarnOption(const wchar_t *s);
 extern void PySys_AddXOption(const wchar_t *s);
 extern void Py_SetPath(const wchar_t *path);
 
+// These functions were removed from Python 3.15 API but are still exported
+// for the stable ABI. We want to test them in this program.
+extern void PySys_ResetWarnOptions(void);
+
 
 int main_argc;
 char **main_argv;
index 832d2afff806ab2b313a0f4db6c4bc8b7f325adb..59baca26793f6c226e32a48bf70ff0d91c848fc6 100644 (file)
@@ -3045,7 +3045,7 @@ get_warnoptions(PyThreadState *tstate)
     return warnoptions;
 }
 
-void
+PyAPI_FUNC(void)
 PySys_ResetWarnOptions(void)
 {
     PyThreadState *tstate = _PyThreadState_GET();