Skip to content

Commit 96be738

Browse files
committed
Use _PyDictKeys_StringLookup and lock around it, rather than wasting out param
1 parent 581869e commit 96be738

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Python/specialize.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,13 @@ specialize_inline_values_access_lock_held(
976976
_PyAttrCache *cache = (_PyAttrCache *)(instr + 1);
977977
assert(PyUnicode_CheckExact(name));
978978
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(owner);
979-
uint32_t version;
980-
Py_ssize_t index = _PyDictKeys_StringLookupAndVersion(keys, name, &version);
979+
#ifdef Py_GIL_DISABLED
980+
PyMutex_LockFlags(&keys->dk_mutex, _Py_LOCK_DONT_DETACH);
981+
#endif
982+
Py_ssize_t index = _PyDictKeys_StringLookup(keys, name);
983+
#ifdef Py_GIL_DISABLED
984+
PyMutex_Unlock(&keys->dk_mutex);
985+
#endif
981986
assert (index != DKIX_ERROR);
982987
if (index == DKIX_EMPTY) {
983988
SPECIALIZATION_FAIL(base_op, SPEC_FAIL_ATTR_NOT_IN_KEYS);

0 commit comments

Comments
 (0)