@@ -1597,7 +1597,7 @@ insertion_resize(PyInterpreterState *interp, PyDictObject *mp, int unicode)
1597
1597
}
1598
1598
1599
1599
static Py_ssize_t
1600
- insert_into_splitdictkeys_locked (PyDictKeysObject * keys , PyObject * name )
1600
+ insert_into_splitdictkeys (PyDictKeysObject * keys , PyObject * name )
1601
1601
{
1602
1602
assert (PyUnicode_CheckExact (name ));
1603
1603
ASSERT_KEYS_LOCKED (keys );
@@ -1629,15 +1629,6 @@ insert_into_splitdictkeys_locked(PyDictKeysObject *keys, PyObject *name)
1629
1629
return ix ;
1630
1630
}
1631
1631
1632
- static Py_ssize_t
1633
- insert_into_splitdictkeys (PyDictKeysObject * keys , PyObject * name )
1634
- {
1635
- LOCK_KEYS (keys );
1636
- Py_ssize_t ix = insert_into_splitdictkeys_locked (keys , name );
1637
- UNLOCK_KEYS (keys );
1638
- return ix ;
1639
- }
1640
-
1641
1632
static inline int
1642
1633
insert_combined_dict (PyInterpreterState * interp , PyDictObject * mp ,
1643
1634
Py_hash_t hash , PyObject * key , PyObject * value )
@@ -6705,17 +6696,16 @@ _PyObject_StoreInstanceAttribute(PyObject *obj, PyDictValues *values,
6705
6696
Py_hash_t hash = unicode_get_hash (name );
6706
6697
if (hash == -1 ) {
6707
6698
hash = PyUnicode_Type .tp_hash (name );
6708
- if (hash == -1 ) {
6709
- PyErr_Clear ();
6710
- return DKIX_EMPTY ;
6711
- }
6699
+ assert (hash != -1 );
6712
6700
}
6713
6701
6714
6702
// Try a thread-safe lookup to see if the index is already allocated
6715
6703
ix = unicodekeys_lookup_unicode_threadsafe (keys , name , hash );
6716
6704
if (ix == DKIX_EMPTY ) {
6717
- // Fall back to a version that will lock and maybe insert
6705
+ // Lock keys and do insert
6706
+ LOCK_KEYS (keys );
6718
6707
ix = insert_into_splitdictkeys (keys , name );
6708
+ UNLOCK_KEYS (keys );
6719
6709
}
6720
6710
#else
6721
6711
ix = insert_into_splitdictkeys (keys , name );
0 commit comments