@@ -1633,7 +1633,7 @@ unicode_modifiable(PyObject *unicode)
16331633 assert (_PyUnicode_CHECK (unicode ));
16341634 if (Py_REFCNT (unicode ) != 1 )
16351635 return 0 ;
1636- if (_PyUnicode_HASH (unicode ) != -1 )
1636+ if (FT_ATOMIC_LOAD_SSIZE_RELAXED ( _PyUnicode_HASH (unicode ) ) != -1 )
16371637 return 0 ;
16381638 if (PyUnicode_CHECK_INTERNED (unicode ))
16391639 return 0 ;
@@ -10901,9 +10901,10 @@ _PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
1090110901 if (PyUnicode_CHECK_INTERNED (left ))
1090210902 return 0 ;
1090310903
10904- assert (_PyUnicode_HASH (right_uni ) != -1 );
10905- Py_hash_t hash = _PyUnicode_HASH (left );
10906- if (hash != -1 && hash != _PyUnicode_HASH (right_uni )) {
10904+ Py_hash_t right_hash = FT_ATOMIC_LOAD_SSIZE_RELAXED (_PyUnicode_HASH (right_uni ));
10905+ assert (right_hash != -1 );
10906+ Py_hash_t hash = FT_ATOMIC_LOAD_SSIZE_RELAXED (_PyUnicode_HASH (left ));
10907+ if (hash != -1 && hash != right_hash ) {
1090710908 return 0 ;
1090810909 }
1090910910
@@ -11388,12 +11389,14 @@ unicode_hash(PyObject *self)
1138811389#ifdef Py_DEBUG
1138911390 assert (_Py_HashSecret_Initialized );
1139011391#endif
11391- if (_PyUnicode_HASH (self ) != -1 )
11392- return _PyUnicode_HASH (self );
11393-
11392+ Py_hash_t hash = FT_ATOMIC_LOAD_SSIZE_RELAXED (_PyUnicode_HASH (self ));
11393+ if (hash != -1 ) {
11394+ return hash ;
11395+ }
1139411396 x = _Py_HashBytes (PyUnicode_DATA (self ),
1139511397 PyUnicode_GET_LENGTH (self ) * PyUnicode_KIND (self ));
11396- _PyUnicode_HASH (self ) = x ;
11398+
11399+ FT_ATOMIC_STORE_SSIZE_RELAXED (_PyUnicode_HASH (self ), x );
1139711400 return x ;
1139811401}
1139911402
0 commit comments