https://github.com/python/cpython
Revision 5d21d884b6ffa45dac50a5f9a07c41356a8478b4 authored by mpage on 29 March 2024, 17:42:02 UTC, committed by GitHub on 29 March 2024, 17:42:02 UTC
Read the MRO in a thread-unsafe way in `PyType_IsSubtype` to avoid locking. Fixing this is tracked in #117306. 

The motivation for this change is in support of making weakrefs thread-safe in free-threaded builds:

`WeakValueDictionary` uses a special dictionary function, `_PyDict_DelItemIf`
to remove dead weakrefs from the dictionary. `_PyDict_DelItemIf` removes a key
if a user supplied predicate evaluates to true for the value associated with
the key. Crucially for the `WeakValueDictionary` use case, the predicate
evaluation + deletion sequence is atomic, provided that the predicate doesn’t
suspend. The predicate used by `WeakValueDictionary` includes a subtype check,
which we must ensure doesn't suspend in free-threaded builds.
1 parent 19c1dd6
History
Tip revision: 5d21d884b6ffa45dac50a5f9a07c41356a8478b4 authored by mpage on 29 March 2024, 17:42:02 UTC
gh-111926: Avoid locking in PyType_IsSubtype (#117275)
Tip revision: 5d21d88
File Mode Size
.azure-pipelines
.devcontainer
.github
Android
Doc
Grammar
Include
Lib
Mac
Misc
Modules
Objects
PC
PCbuild
Parser
Programs
Python
Tools
iOS
.coveragerc -rw-r--r-- 526 bytes
.editorconfig -rw-r--r-- 214 bytes
.gitattributes -rw-r--r-- 3.9 KB
.gitignore -rw-r--r-- 3.1 KB
.mailmap -rw-r--r-- 175 bytes
.pre-commit-config.yaml -rw-r--r-- 1.1 KB
.readthedocs.yml -rw-r--r-- 1014 bytes
LICENSE -rw-r--r-- 13.5 KB
Makefile.pre.in -rw-r--r-- 116.4 KB
README.rst -rw-r--r-- 8.6 KB
aclocal.m4 -rw-r--r-- 23.7 KB
config.guess -rwxr-xr-x 48.2 KB
config.sub -rwxr-xr-x 36.1 KB
configure -rwxr-xr-x 857.2 KB
configure.ac -rw-r--r-- 239.3 KB
install-sh -rwxr-xr-x 15.0 KB
pyconfig.h.in -rw-r--r-- 53.5 KB

README.rst

back to top