Skip to content

Commit dd86217

Browse files
authored
[3.12] GH-122085: Use include files for C API deprecations (GH-109843) (#122423)
(cherry picked from commit 76bdfa4)
1 parent 220e31a commit dd86217

File tree

5 files changed

+110
-83
lines changed

5 files changed

+110
-83
lines changed

Diff for: Doc/deprecations/c-api-pending-removal-in-3.14.rst

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Pending Removal in Python 3.14
2+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3+
4+
* The ``ma_version_tag`` field in :c:type:`PyDictObject` for extension modules
5+
(:pep:`699`; :gh:`101193`).
6+
7+
* Creating :c:data:`immutable types <Py_TPFLAGS_IMMUTABLETYPE>` with mutable
8+
bases (:gh:`95388`).
9+
10+
* Functions to configure Python's initialization, deprecated in Python 3.11:
11+
12+
* ``PySys_SetArgvEx()``: set :c:member:`PyConfig.argv` instead.
13+
* ``PySys_SetArgv()``: set :c:member:`PyConfig.argv` instead.
14+
* ``Py_SetProgramName()``: set :c:member:`PyConfig.program_name` instead.
15+
* ``Py_SetPythonHome()``: set :c:member:`PyConfig.home` instead.
16+
17+
The :c:func:`Py_InitializeFromConfig` API should be used with
18+
:c:type:`PyConfig` instead.
19+
20+
* Global configuration variables:
21+
22+
* :c:var:`Py_DebugFlag`: use :c:member:`PyConfig.parser_debug` instead.
23+
* :c:var:`Py_VerboseFlag`: use :c:member:`PyConfig.verbose` instead.
24+
* :c:var:`Py_QuietFlag`: use :c:member:`PyConfig.quiet` instead.
25+
* :c:var:`Py_InteractiveFlag`: use :c:member:`PyConfig.interactive` instead.
26+
* :c:var:`Py_InspectFlag`: use :c:member:`PyConfig.inspect` instead.
27+
* :c:var:`Py_OptimizeFlag`: use :c:member:`PyConfig.optimization_level` instead.
28+
* :c:var:`Py_NoSiteFlag`: use :c:member:`PyConfig.site_import` instead.
29+
* :c:var:`Py_BytesWarningFlag`: use :c:member:`PyConfig.bytes_warning` instead.
30+
* :c:var:`Py_FrozenFlag`: use :c:member:`PyConfig.pathconfig_warnings` instead.
31+
* :c:var:`Py_IgnoreEnvironmentFlag`: use :c:member:`PyConfig.use_environment` instead.
32+
* :c:var:`Py_DontWriteBytecodeFlag`: use :c:member:`PyConfig.write_bytecode` instead.
33+
* :c:var:`Py_NoUserSiteDirectory`: use :c:member:`PyConfig.user_site_directory` instead.
34+
* :c:var:`Py_UnbufferedStdioFlag`: use :c:member:`PyConfig.buffered_stdio` instead.
35+
* :c:var:`Py_HashRandomizationFlag`: use :c:member:`PyConfig.use_hash_seed`
36+
and :c:member:`PyConfig.hash_seed` instead.
37+
* :c:var:`Py_IsolatedFlag`: use :c:member:`PyConfig.isolated` instead.
38+
* :c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyPreConfig.legacy_windows_fs_encoding` instead.
39+
* :c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig.legacy_windows_stdio` instead.
40+
* :c:var:`!Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig.filesystem_encoding` instead.
41+
* :c:var:`!Py_HasFileSystemDefaultEncoding`: use :c:member:`PyConfig.filesystem_encoding` instead.
42+
* :c:var:`!Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig.filesystem_errors` instead.
43+
* :c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` instead. (see :c:func:`Py_PreInitialize`)
44+
45+
The :c:func:`Py_InitializeFromConfig` API should be used with
46+
:c:type:`PyConfig` instead.

Diff for: Doc/deprecations/c-api-pending-removal-in-3.15.rst

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Pending Removal in Python 3.15
2+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3+
4+
* The bundled copy of ``libmpdecimal``.
5+
* :c:func:`PyImport_ImportModuleNoBlock`: use :c:func:`PyImport_ImportModule` instead.
6+
* :c:func:`PyWeakref_GET_OBJECT`: use :c:func:`!PyWeakref_GetRef` instead.
7+
* :c:func:`PyWeakref_GetObject`: use :c:func:`!PyWeakref_GetRef` instead.
8+
* :c:type:`!Py_UNICODE_WIDE` type: use :c:type:`wchar_t` instead.
9+
* :c:type:`Py_UNICODE` type: use :c:type:`wchar_t` instead.
10+
* Python initialization functions:
11+
12+
* :c:func:`PySys_ResetWarnOptions`: clear :data:`sys.warnoptions` and
13+
:data:`!warnings.filters` instead.
14+
* :c:func:`Py_GetExecPrefix`: get :data:`sys.exec_prefix` instead.
15+
* :c:func:`Py_GetPath`: get :data:`sys.path` instead.
16+
* :c:func:`Py_GetPrefix`: get :data:`sys.prefix` instead.
17+
* :c:func:`Py_GetProgramFullPath`: get :data:`sys.executable` instead.
18+
* :c:func:`Py_GetProgramName`: get :data:`sys.executable` instead.
19+
* :c:func:`Py_GetPythonHome`: get :c:member:`PyConfig.home` or
20+
the :envvar:`PYTHONHOME` environment variable instead.

Diff for: Doc/deprecations/c-api-pending-removal-in-future.rst

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Pending Removal in Future Versions
2+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3+
4+
The following APIs are deprecated and will be removed,
5+
although there is currently no date scheduled for their removal.
6+
7+
* :c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: unneeded since Python 3.8.
8+
* :c:func:`PyErr_Fetch`: use :c:func:`PyErr_GetRaisedException` instead.
9+
* :c:func:`PyErr_NormalizeException`: use :c:func:`PyErr_GetRaisedException` instead.
10+
* :c:func:`PyErr_Restore`: use :c:func:`PyErr_SetRaisedException` instead.
11+
* :c:func:`PyModule_GetFilename`: use :c:func:`PyModule_GetFilenameObject` instead.
12+
* :c:func:`PyOS_AfterFork`: use :c:func:`PyOS_AfterFork_Child` instead.
13+
* :c:func:`PySlice_GetIndicesEx`: use :c:func:`PySlice_Unpack` and :c:func:`PySlice_AdjustIndices` instead.
14+
* :c:func:`!PyUnicode_AsDecodedObject`: use :c:func:`PyCodec_Decode` instead.
15+
* :c:func:`!PyUnicode_AsDecodedUnicode`: use :c:func:`PyCodec_Decode` instead.
16+
* :c:func:`!PyUnicode_AsEncodedObject`: use :c:func:`PyCodec_Encode` instead.
17+
* :c:func:`!PyUnicode_AsEncodedUnicode`: use :c:func:`PyCodec_Encode` instead.
18+
* :c:func:`PyUnicode_READY`: unneeded since Python 3.12
19+
* :c:func:`!PyErr_Display`: use :c:func:`PyErr_DisplayException` instead.
20+
* :c:func:`!_PyErr_ChainExceptions`: use ``_PyErr_ChainExceptions1`` instead.
21+
* :c:member:`!PyBytesObject.ob_shash` member:
22+
call :c:func:`PyObject_Hash` instead.
23+
* :c:member:`!PyDictObject.ma_version_tag` member.
24+
* Thread Local Storage (TLS) API:
25+
26+
* :c:func:`PyThread_create_key`: use :c:func:`PyThread_tss_alloc` instead.
27+
* :c:func:`PyThread_delete_key`: use :c:func:`PyThread_tss_free` instead.
28+
* :c:func:`PyThread_set_key_value`: use :c:func:`PyThread_tss_set` instead.
29+
* :c:func:`PyThread_get_key_value`: use :c:func:`PyThread_tss_get` instead.
30+
* :c:func:`PyThread_delete_key_value`: use :c:func:`PyThread_tss_delete` instead.
31+
* :c:func:`PyThread_ReInitTLS`: unneeded since Python 3.7.

Diff for: Doc/deprecations/index.rst

+9
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@ Deprecations
1010
.. include:: pending-removal-in-3.16.rst
1111

1212
.. include:: pending-removal-in-future.rst
13+
14+
C API Deprecations
15+
------------------
16+
17+
.. include:: c-api-pending-removal-in-3.14.rst
18+
19+
.. include:: c-api-pending-removal-in-3.15.rst
20+
21+
.. include:: c-api-pending-removal-in-future.rst

Diff for: Doc/whatsnew/3.12.rst

+4-83
Original file line numberDiff line numberDiff line change
@@ -2221,92 +2221,13 @@ Deprecated
22212221
overrides :c:member:`~PyTypeObject.tp_new` is deprecated.
22222222
Call the metaclass instead.
22232223

2224-
Pending Removal in Python 3.14
2225-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2224+
.. Add deprecations above alphabetically, not here at the end.
22262225
2227-
* The ``ma_version_tag`` field in :c:type:`PyDictObject` for extension modules
2228-
(:pep:`699`; :gh:`101193`).
2226+
.. include:: ../deprecations/c-api-pending-removal-in-3.14.rst
22292227

2230-
* Global configuration variables:
2228+
.. include:: ../deprecations/c-api-pending-removal-in-3.15.rst
22312229

2232-
* :c:var:`Py_DebugFlag`: use :c:member:`PyConfig.parser_debug`
2233-
* :c:var:`Py_VerboseFlag`: use :c:member:`PyConfig.verbose`
2234-
* :c:var:`Py_QuietFlag`: use :c:member:`PyConfig.quiet`
2235-
* :c:var:`Py_InteractiveFlag`: use :c:member:`PyConfig.interactive`
2236-
* :c:var:`Py_InspectFlag`: use :c:member:`PyConfig.inspect`
2237-
* :c:var:`Py_OptimizeFlag`: use :c:member:`PyConfig.optimization_level`
2238-
* :c:var:`Py_NoSiteFlag`: use :c:member:`PyConfig.site_import`
2239-
* :c:var:`Py_BytesWarningFlag`: use :c:member:`PyConfig.bytes_warning`
2240-
* :c:var:`Py_FrozenFlag`: use :c:member:`PyConfig.pathconfig_warnings`
2241-
* :c:var:`Py_IgnoreEnvironmentFlag`: use :c:member:`PyConfig.use_environment`
2242-
* :c:var:`Py_DontWriteBytecodeFlag`: use :c:member:`PyConfig.write_bytecode`
2243-
* :c:var:`Py_NoUserSiteDirectory`: use :c:member:`PyConfig.user_site_directory`
2244-
* :c:var:`Py_UnbufferedStdioFlag`: use :c:member:`PyConfig.buffered_stdio`
2245-
* :c:var:`Py_HashRandomizationFlag`: use :c:member:`PyConfig.use_hash_seed`
2246-
and :c:member:`PyConfig.hash_seed`
2247-
* :c:var:`Py_IsolatedFlag`: use :c:member:`PyConfig.isolated`
2248-
* :c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyPreConfig.legacy_windows_fs_encoding`
2249-
* :c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig.legacy_windows_stdio`
2250-
* :c:var:`!Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig.filesystem_encoding`
2251-
* :c:var:`!Py_HasFileSystemDefaultEncoding`: use :c:member:`PyConfig.filesystem_encoding`
2252-
* :c:var:`!Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig.filesystem_errors`
2253-
* :c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` (see :c:func:`Py_PreInitialize`)
2254-
2255-
The :c:func:`Py_InitializeFromConfig` API should be used with
2256-
:c:type:`PyConfig` instead.
2257-
2258-
* Creating :c:data:`immutable types <Py_TPFLAGS_IMMUTABLETYPE>` with mutable
2259-
bases (:gh:`95388`).
2260-
2261-
Pending Removal in Python 3.15
2262-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2263-
2264-
* :c:func:`PyImport_ImportModuleNoBlock`: use :c:func:`PyImport_ImportModule`
2265-
* :c:type:`!Py_UNICODE_WIDE` type: use :c:type:`wchar_t`
2266-
* :c:type:`Py_UNICODE` type: use :c:type:`wchar_t`
2267-
* Python initialization functions:
2268-
2269-
* :c:func:`PySys_ResetWarnOptions`: clear :data:`sys.warnoptions` and
2270-
:data:`!warnings.filters`
2271-
* :c:func:`Py_GetExecPrefix`: get :data:`sys.exec_prefix`
2272-
* :c:func:`Py_GetPath`: get :data:`sys.path`
2273-
* :c:func:`Py_GetPrefix`: get :data:`sys.prefix`
2274-
* :c:func:`Py_GetProgramFullPath`: get :data:`sys.executable`
2275-
* :c:func:`Py_GetProgramName`: get :data:`sys.executable`
2276-
* :c:func:`Py_GetPythonHome`: get :c:member:`PyConfig.home` or
2277-
the :envvar:`PYTHONHOME` environment variable
2278-
2279-
Pending Removal in Future Versions
2280-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2281-
2282-
The following APIs are deprecated and will be removed,
2283-
although there is currently no date scheduled for their removal.
2284-
2285-
* :c:macro:`Py_TPFLAGS_HAVE_FINALIZE`: unneeded since Python 3.8
2286-
* :c:func:`PyErr_Fetch`: use :c:func:`PyErr_GetRaisedException`
2287-
* :c:func:`PyErr_NormalizeException`: use :c:func:`PyErr_GetRaisedException`
2288-
* :c:func:`PyErr_Restore`: use :c:func:`PyErr_SetRaisedException`
2289-
* :c:func:`PyModule_GetFilename`: use :c:func:`PyModule_GetFilenameObject`
2290-
* :c:func:`PyOS_AfterFork`: use :c:func:`PyOS_AfterFork_Child`
2291-
* :c:func:`PySlice_GetIndicesEx`: use :c:func:`PySlice_Unpack` and :c:func:`PySlice_AdjustIndices`
2292-
* :c:func:`!PyUnicode_AsDecodedObject`: use :c:func:`PyCodec_Decode`
2293-
* :c:func:`!PyUnicode_AsDecodedUnicode`: use :c:func:`PyCodec_Decode`
2294-
* :c:func:`!PyUnicode_AsEncodedObject`: use :c:func:`PyCodec_Encode`
2295-
* :c:func:`!PyUnicode_AsEncodedUnicode`: use :c:func:`PyCodec_Encode`
2296-
* :c:func:`PyUnicode_READY`: unneeded since Python 3.12
2297-
* :c:func:`!PyErr_Display`: use :c:func:`PyErr_DisplayException`
2298-
* :c:func:`!_PyErr_ChainExceptions`: use ``_PyErr_ChainExceptions1``
2299-
* :c:member:`!PyBytesObject.ob_shash` member:
2300-
call :c:func:`PyObject_Hash` instead
2301-
* :c:member:`!PyDictObject.ma_version_tag` member
2302-
* Thread Local Storage (TLS) API:
2303-
2304-
* :c:func:`PyThread_create_key`: use :c:func:`PyThread_tss_alloc`
2305-
* :c:func:`PyThread_delete_key`: use :c:func:`PyThread_tss_free`
2306-
* :c:func:`PyThread_set_key_value`: use :c:func:`PyThread_tss_set`
2307-
* :c:func:`PyThread_get_key_value`: use :c:func:`PyThread_tss_get`
2308-
* :c:func:`PyThread_delete_key_value`: use :c:func:`PyThread_tss_delete`
2309-
* :c:func:`PyThread_ReInitTLS`: unneeded since Python 3.7
2230+
.. include:: ../deprecations/c-api-pending-removal-in-future.rst
23102231

23112232
Removed
23122233
-------

0 commit comments

Comments
 (0)