Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all 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
33 changes: 0 additions & 33 deletions 33 Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1208,39 +1208,6 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
available (even when threads have not been initialized).


.. c:function:: void PyEval_AcquireLock()

Acquire the global interpreter lock. The lock must have been created earlier.
If this thread already has the lock, a deadlock ensues.

.. deprecated:: 3.2
This function does not update the current thread state. Please use
:c:func:`PyEval_RestoreThread` or :c:func:`PyEval_AcquireThread`
instead.

.. note::
Calling this function from a thread when the runtime is finalizing
will terminate the thread, even if the thread was not created by Python.
You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to
check if the interpreter is in process of being finalized before calling
this function to avoid unwanted termination.

.. versionchanged:: 3.8
Updated to be consistent with :c:func:`PyEval_RestoreThread`,
:c:func:`Py_END_ALLOW_THREADS`, and :c:func:`PyGILState_Ensure`,
and terminate the current thread if called while the interpreter is finalizing.


.. c:function:: void PyEval_ReleaseLock()

Release the global interpreter lock. The lock must have been created earlier.

.. deprecated:: 3.2
This function does not update the current thread state. Please use
:c:func:`PyEval_SaveThread` or :c:func:`PyEval_ReleaseThread`
instead.


.. _sub-interpreter-support:

Sub-interpreter support
Expand Down
4 changes: 0 additions & 4 deletions 4 Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,6 @@ PyErr_WarnFormat::...::
PyErr_WriteUnraisable:void:::
PyErr_WriteUnraisable:PyObject*:obj:0:

PyEval_AcquireLock:void:::

PyEval_AcquireThread:void:::
PyEval_AcquireThread:PyThreadState*:tstate::

Expand All @@ -782,8 +780,6 @@ PyEval_GetFuncName:PyObject*:func:0:

PyEval_InitThreads:void:::

PyEval_ReleaseLock:void:::

PyEval_ReleaseThread:void:::
PyEval_ReleaseThread:PyThreadState*:tstate::

Expand Down
8 changes: 8 additions & 0 deletions 8 Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,14 @@ Build and C API Changes
scheduled calls.
(Contributed by Victor Stinner in :issue:`39984`.)

* The misleading ``PyEval_AcquireLock()`` and ``PyEval_ReleaseLock()``
functions have been removed. These functions were deprecated since Python 3.2
and did not update the current thread state. Instead, use
:c:func:`PyEval_SaveThread` with :c:func:`PyEval_RestoreThread`,
or :c:func:`PyEval_AcquireThread` with :c:func:`PyEval_ReleaseThread`,
which are thread-state aware APIs.
(Contributed by Victor Stinner in :issue:`39998`.)


Deprecated
==========
Expand Down
2 changes: 0 additions & 2 deletions 2 Include/ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);

Py_DEPRECATED(3.9) PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_AcquireLock(void);
/* Py_DEPRECATED(3.2) */ PyAPI_FUNC(void) PyEval_ReleaseLock(void);
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The misleading ``PyEval_AcquireLock()`` and ``PyEval_ReleaseLock()``
functions have been removed. These functions were deprecated since Python 3.2
and did not update the current thread state. Instead, use
:c:func:`PyEval_SaveThread` with :c:func:`PyEval_RestoreThread`, or
:c:func:`PyEval_AcquireThread` with :c:func:`PyEval_ReleaseThread`, which
are thread-state aware APIs.
2 changes: 0 additions & 2 deletions 2 PC/python3.def
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ EXPORTS
PyErr_WarnExplicit=python39.PyErr_WarnExplicit
PyErr_WarnFormat=python39.PyErr_WarnFormat
PyErr_WriteUnraisable=python39.PyErr_WriteUnraisable
PyEval_AcquireLock=python39.PyEval_AcquireLock
PyEval_AcquireThread=python39.PyEval_AcquireThread
PyEval_CallFunction=python39.PyEval_CallFunction
PyEval_CallMethod=python39.PyEval_CallMethod
Expand All @@ -176,7 +175,6 @@ EXPORTS
PyEval_GetLocals=python39.PyEval_GetLocals
PyEval_InitThreads=python39.PyEval_InitThreads
PyEval_ReInitThreads=python39.PyEval_ReInitThreads
PyEval_ReleaseLock=python39.PyEval_ReleaseLock
PyEval_ReleaseThread=python39.PyEval_ReleaseThread
PyEval_RestoreThread=python39.PyEval_RestoreThread
PyEval_SaveThread=python39.PyEval_SaveThread
Expand Down
20 changes: 0 additions & 20 deletions 20 Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,26 +352,6 @@ _PyEval_Fini(void)
#endif
}

void
PyEval_AcquireLock(void)
{
_PyRuntimeState *runtime = &_PyRuntime;
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
ensure_tstate_not_null(__func__, tstate);

take_gil(tstate);
}

void
PyEval_ReleaseLock(void)
{
_PyRuntimeState *runtime = &_PyRuntime;
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
/* This function must succeed when the current thread state is NULL.
We therefore avoid PyThreadState_Get() which dumps a fatal error
in debug mode. */
drop_gil(&runtime->ceval, tstate);
}

void
_PyEval_ReleaseLock(PyThreadState *tstate)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.