Skip to content

Commit a885673

Browse files
committed
gh-154757: Remove deprecated PyEval_InitThreads() function
1 parent 09bf4c5 commit a885673

9 files changed

Lines changed: 11 additions & 34 deletions

File tree

‎Doc/c-api/interp-lifecycle.rst‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ The following functions can be safely called before Python is initialized:
7474

7575
Despite their apparent similarity to some of the functions listed above,
7676
the following functions **should not be called** before the interpreter has
77-
been initialized: :c:func:`Py_EncodeLocale`, :c:func:`PyEval_InitThreads`, and
78-
:c:func:`Py_RunMain`.
77+
been initialized: :c:func:`Py_EncodeLocale`, and :c:func:`Py_RunMain`.
7978

8079

8180
.. _global-conf-vars:
@@ -355,7 +354,6 @@ Initializing and finalizing the interpreter
355354
.. c:function:: void Py_Initialize()
356355
357356
.. index::
358-
single: PyEval_InitThreads()
359357
single: modules (in module sys)
360358
single: path (in module sys)
361359
pair: module; builtins

‎Doc/c-api/threads.rst‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -577,33 +577,6 @@ C extensions.
577577
This thread's interpreter state.
578578
579579
580-
.. c:function:: void PyEval_InitThreads()
581-
582-
.. index::
583-
single: PyEval_AcquireThread()
584-
single: PyEval_ReleaseThread()
585-
single: PyEval_SaveThread()
586-
single: PyEval_RestoreThread()
587-
588-
Deprecated function which does nothing.
589-
590-
In Python 3.6 and older, this function created the GIL if it didn't exist.
591-
592-
.. versionchanged:: 3.9
593-
The function now does nothing.
594-
595-
.. versionchanged:: 3.7
596-
This function is now called by :c:func:`Py_Initialize()`, so you don't
597-
have to call it yourself anymore.
598-
599-
.. versionchanged:: 3.2
600-
This function cannot be called before :c:func:`Py_Initialize()` anymore.
601-
602-
.. deprecated:: 3.9
603-
604-
.. index:: pair: module; _thread
605-
606-
607580
.. c:function:: PyThreadState* PyEval_SaveThread()
608581
609582
Detach the :term:`attached thread state` and return it.

‎Doc/data/stable_abi.dat‎

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Doc/tools/removed-ids.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Remove from here in 3.16
44
c-api/allocation.html: deprecated-aliases
55
c-api/file.html: deprecated-api
6+
c-api/threads.html: c.PyEval_InitThreads
67

78
# Removed sections
89
library/asyncio-task.html: terminating-a-task-group

‎Doc/whatsnew/3.16.rst‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,10 @@ Deprecated C APIs
11411141
Removed C APIs
11421142
--------------
11431143

1144+
* Remove :c:func:`!PyEval_InitThreads` function which did nothing since Python
1145+
3.7 and was deprecated since Python 3.9.
1146+
(Contributed by Victor Stinner in :gh:`154757`.)
1147+
11441148
* The :c:var:`!PyUnstable_ExecutableKinds` array, as well as the macros
11451149
:c:macro:`!PyUnstable_EXECUTABLE_KIND_SKIP`,
11461150
:c:macro:`!PyUnstable_EXECUTABLE_KIND_PY_FUNCTION`,

‎Include/ceval.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(PyFrameObject *f, int exc);
111111
PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
112112
PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
113113

114-
Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
115-
116114
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
117115
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
118116

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove :c:func:`!PyEval_InitThreads` function which did nothing since Python
2+
3.7 and was deprecated since Python 3.9. Patch by Victor Stinner.

‎Misc/stable_abi.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@
715715
added = '3.2'
716716
[function.PyEval_InitThreads]
717717
added = '3.2'
718+
abi_only = true
718719
[function.PyEval_ReleaseLock]
719720
added = '3.2'
720721
abi_only = true

‎Python/ceval_gil.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ _PyEval_FiniGIL(PyInterpreterState *interp)
550550
interp->ceval.gil = NULL;
551551
}
552552

553-
void
553+
// Function removed in Python 3.16 limited C API, but kept in the stable ABI
554+
PyAPI_FUNC(void)
554555
PyEval_InitThreads(void)
555556
{
556557
/* Do nothing: kept for backward compatibility */

0 commit comments

Comments
 (0)