]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-125053: Document that ob_mutex must only be used via critical section API (#144599)
authorFarhan Saif <farhansaif488@gmail.com>
Tue, 10 Mar 2026 16:23:39 +0000 (11:23 -0500)
committerGitHub <noreply@github.com>
Tue, 10 Mar 2026 16:23:39 +0000 (17:23 +0100)
commitbf4017b16149ba17d723abacfe93aec79b2235fe
tree623a2d5e2633de249bddf341e5dc99393c1f42a8
parent2756d56eefe86c4df696d8c65e21e4583ffe7511
gh-125053: Document that ob_mutex must only be used via critical section API (#144599)

Add a warning in the free-threading extensions howto explaining that
PyObject.ob_mutex is reserved for the critical section API and must not
be locked directly with PyMutex_Lock, as this can cause deadlocks.
Extension authors who need their own lock should add a separate PyMutex
field to their object struct.

Also add an ob_mutex member entry under PyObject in the C API reference
(Doc/c-api/structures.rst) with a cross-reference to the howto.

Co-authored-by: Victor Stinner <vstinner@python.org>
Doc/c-api/structures.rst
Doc/howto/free-threading-extensions.rst