]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-120858: PyDict_Next should not lock the dict (#120859)
authorSam Gross <colesbury@gmail.com>
Mon, 24 Jun 2024 18:15:15 +0000 (14:15 -0400)
committerGitHub <noreply@github.com>
Mon, 24 Jun 2024 18:15:15 +0000 (14:15 -0400)
commit375b723d5873f948696c7e85a97f4778d9e00ff0
tree081f3b0fffac79d58c7b1e3cc81e8a9bdc2e3373
parentdee63cb35971b87a09ddda5d6f29cd941f570720
gh-120858: PyDict_Next should not lock the dict (#120859)

PyDict_Next no longer locks the dictionary in the free-threaded build. Locking
around individual PyDict_Next calls is not sufficient because the function
returns borrowed references and because it allows concurrent modifications
during the iteraiton loop.

The internal locking also interferes with correct external synchronization
because it may suspend outer critical sections created by the caller.
Doc/c-api/dict.rst
Doc/howto/free-threading-extensions.rst
Misc/NEWS.d/next/C API/2024-06-21-16-41-21.gh-issue-120858.Z5_-Mn.rst [new file with mode: 0644]
Objects/dictobject.c