@@ -1625,7 +1625,7 @@ unicode_modifiable(PyObject *unicode)
16251625 assert (_PyUnicode_CHECK (unicode ));
16261626 if (Py_REFCNT (unicode ) != 1 )
16271627 return 0 ;
1628- if (_PyUnicode_HASH (unicode ) != -1 )
1628+ if (FT_ATOMIC_LOAD_SSIZE_RELAXED ( _PyUnicode_HASH (unicode ) ) != -1 )
16291629 return 0 ;
16301630 if (PyUnicode_CHECK_INTERNED (unicode ))
16311631 return 0 ;
@@ -10819,9 +10819,10 @@ _PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
1081910819 if (PyUnicode_CHECK_INTERNED (left ))
1082010820 return 0 ;
1082110821
10822- assert (_PyUnicode_HASH (right_uni ) != -1 );
10823- Py_hash_t hash = _PyUnicode_HASH (left );
10824- if (hash != -1 && hash != _PyUnicode_HASH (right_uni )) {
10822+ Py_hash_t right_hash = FT_ATOMIC_LOAD_SSIZE_RELAXED (_PyUnicode_HASH (right_uni ));
10823+ assert (right_hash != -1 );
10824+ Py_hash_t hash = FT_ATOMIC_LOAD_SSIZE_RELAXED (_PyUnicode_HASH (left ));
10825+ if (hash != -1 && hash != right_hash ) {
1082510826 return 0 ;
1082610827 }
1082710828
@@ -11306,12 +11307,14 @@ unicode_hash(PyObject *self)
1130611307#ifdef Py_DEBUG
1130711308 assert (_Py_HashSecret_Initialized );
1130811309#endif
11309- if (_PyUnicode_HASH (self ) != -1 )
11310- return _PyUnicode_HASH (self );
11311-
11310+ Py_hash_t hash = FT_ATOMIC_LOAD_SSIZE_RELAXED (_PyUnicode_HASH (self ));
11311+ if (hash != -1 ) {
11312+ return hash ;
11313+ }
1131211314 x = _Py_HashBytes (PyUnicode_DATA (self ),
1131311315 PyUnicode_GET_LENGTH (self ) * PyUnicode_KIND (self ));
11314- _PyUnicode_HASH (self ) = x ;
11316+
11317+ FT_ATOMIC_STORE_SSIZE_RELAXED (_PyUnicode_HASH (self ), x );
1131511318 return x ;
1131611319}
1131711320
0 commit comments