@@ -1625,7 +1625,7 @@ unicode_modifiable(PyObject *unicode)
1625
1625
assert (_PyUnicode_CHECK (unicode ));
1626
1626
if (Py_REFCNT (unicode ) != 1 )
1627
1627
return 0 ;
1628
- if (_PyUnicode_HASH (unicode ) != -1 )
1628
+ if (FT_ATOMIC_LOAD_SSIZE_RELAXED ( _PyUnicode_HASH (unicode ) ) != -1 )
1629
1629
return 0 ;
1630
1630
if (PyUnicode_CHECK_INTERNED (unicode ))
1631
1631
return 0 ;
@@ -10819,9 +10819,10 @@ _PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
10819
10819
if (PyUnicode_CHECK_INTERNED (left ))
10820
10820
return 0 ;
10821
10821
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 ) {
10825
10826
return 0 ;
10826
10827
}
10827
10828
@@ -11306,12 +11307,14 @@ unicode_hash(PyObject *self)
11306
11307
#ifdef Py_DEBUG
11307
11308
assert (_Py_HashSecret_Initialized );
11308
11309
#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
+ }
11312
11314
x = _Py_HashBytes (PyUnicode_DATA (self ),
11313
11315
PyUnicode_GET_LENGTH (self ) * PyUnicode_KIND (self ));
11314
- _PyUnicode_HASH (self ) = x ;
11316
+
11317
+ FT_ATOMIC_STORE_SSIZE_RELAXED (_PyUnicode_HASH (self ), x );
11315
11318
return x ;
11316
11319
}
11317
11320
0 commit comments