1
0
mirror of https://github.com/python/cpython synced 2024-07-05 18:43:34 +00:00
cpython/Include
Brett Simmers be1dfccdf2
gh-118727: Don't drop the GIL in drop_gil() unless the current thread holds it (#118745)
`drop_gil()` assumes that its caller is attached, which means that the current
thread holds the GIL if and only if the GIL is enabled, and the enabled-state
of the GIL won't change. This isn't true, though, because `detach_thread()`
calls `_PyEval_ReleaseLock()` after detaching and
`_PyThreadState_DeleteCurrent()` calls it after removing the current thread
from consideration for stop-the-world requests (effectively detaching it).

Fix this by remembering whether or not a thread acquired the GIL when it last
attached, in `PyThreadState._status.holds_gil`, and check this in `drop_gil()`
instead of `gil->enabled`.

This fixes a crash in `test_multiprocessing_pool_circular_import()`, so I've
reenabled it.
2024-05-23 16:59:35 -04:00
..
cpython gh-118727: Don't drop the GIL in drop_gil() unless the current thread holds it (#118745) 2024-05-23 16:59:35 -04:00
internal gh-118727: Don't drop the GIL in drop_gil() unless the current thread holds it (#118745) 2024-05-23 16:59:35 -04:00
abstract.h gh-119391: Amend comment description of PyMapping_Items, PyMapping_Values and PyMapping_Keys (#119392) 2024-05-22 08:52:36 -04:00
bltinmodule.h
boolobject.h
bytearrayobject.h
bytesobject.h
ceval.h gh-74929: Implement PEP 667 (GH-115153) 2024-05-04 12:12:10 +01:00
codecs.h
compile.h
complexobject.h
datetime.h
descrobject.h
dictobject.h
dynamic_annotations.h
enumobject.h
errcode.h
exports.h
fileobject.h
fileutils.h
floatobject.h
frameobject.h
genericaliasobject.h
import.h
intrcheck.h
iterobject.h
listobject.h
longobject.h
marshal.h
memoryobject.h
methodobject.h
modsupport.h
moduleobject.h gh-116322: Rename PyModule_ExperimentalSetGIL to PyUnstable_Module_SetGIL (GH-118645) 2024-05-06 18:59:36 +02:00
monitoring.h gh-111997: C-API for signalling monitoring events (#116413) 2024-05-04 08:23:50 +00:00
object.h gh-117657: Fix race data race in _Py_IsOwnedByCurrentThread() (#118258) 2024-04-26 10:39:08 -04:00
objimpl.h
opcode_ids.h gh-119180: Add LOAD_COMMON_CONSTANT opcode (#119321) 2024-05-22 00:46:39 +00:00
opcode.h
osdefs.h
osmodule.h
patchlevel.h Python 3.14.0a0 2024-05-08 16:57:05 +02:00
py_curses.h gh-109617: fix ncurses incompatibility on macOS with Xcode 15 (#111258) 2024-05-04 23:41:47 +02:00
pyatomic.h
pybuffer.h
pycapsule.h
pydtrace.d
pydtrace.h
pyerrors.h
pyexpat.h
pyframe.h
pyhash.h
pylifecycle.h gh-117987: Restore several functions removed in Python 3.13 alpha 1 (GH-117993) 2024-04-18 15:20:38 +02:00
pymacconfig.h
pymacro.h gh-118124: Use static_assert() in Py_BUILD_ASSERT() on C11 (#118398) 2024-04-30 22:29:48 +02:00
pymath.h
pymem.h
pyport.h
pystate.h
pystats.h
pystrcmp.h
pystrtod.h
Python.h gh-111997: C-API for signalling monitoring events (#116413) 2024-05-04 08:23:50 +00:00
pythonrun.h
pythread.h
pytypedefs.h
rangeobject.h
README.rst
setobject.h
sliceobject.h
structmember.h
structseq.h
sysmodule.h gh-117987: Restore several functions removed in Python 3.13 alpha 1 (GH-117993) 2024-04-18 15:20:38 +02:00
traceback.h
tupleobject.h
typeslots.h
unicodeobject.h
warnings.h
weakrefobject.h

The Python C API
================

The C API is divided into these sections:

1. ``Include/``: Limited API
2. ``Include/cpython/``: CPython implementation details
3. ``Include/cpython/``, names with the ``PyUnstable_`` prefix: API that can
   change between minor releases
4. ``Include/internal/``, and any name with ``_`` prefix: The internal API

Information on changing the C API is available `in the developer guide`_

.. _in the developer guide: https://devguide.python.org/c-api/