gh-144295: Fix data race in dict method lookup and global load (gh-144312)
In `_PyDict_GetMethodStackRef`, only use the fast-path unicode lookup when the dict is owned by the current thread or already marked as shared. This prevents a race between the lookup and concurrent dict resizes, which may free the PyDictKeysObject (i.e., it ensures that the resize uses QSBR). Address a similar issue in `_Py_dict_lookup_threadsafe_stackref` by calling `ensure_shared_on_read()`.
S
Sam Gross committed
e666a01ef42939f77f4c22ca47a610df5ef8b7ab
Parent: 1dc12b2
Committed by GitHub <noreply@github.com>
on 1/30/2026, 4:14:10 PM