@@ -1633,7 +1633,7 @@ unicode_modifiable(PyObject *unicode)
1633
1633
assert (_PyUnicode_CHECK (unicode ));
1634
1634
if (Py_REFCNT (unicode ) != 1 )
1635
1635
return 0 ;
1636
- if (_PyUnicode_HASH (unicode ) != -1 )
1636
+ if (FT_ATOMIC_LOAD_SSIZE_RELAXED ( _PyUnicode_HASH (unicode ) ) != -1 )
1637
1637
return 0 ;
1638
1638
if (PyUnicode_CHECK_INTERNED (unicode ))
1639
1639
return 0 ;
@@ -10901,9 +10901,10 @@ _PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
10901
10901
if (PyUnicode_CHECK_INTERNED (left ))
10902
10902
return 0 ;
10903
10903
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 ) {
10907
10908
return 0 ;
10908
10909
}
10909
10910
@@ -11388,12 +11389,14 @@ unicode_hash(PyObject *self)
11388
11389
#ifdef Py_DEBUG
11389
11390
assert (_Py_HashSecret_Initialized );
11390
11391
#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
+ }
11394
11396
x = _Py_HashBytes (PyUnicode_DATA (self ),
11395
11397
PyUnicode_GET_LENGTH (self ) * PyUnicode_KIND (self ));
11396
- _PyUnicode_HASH (self ) = x ;
11398
+
11399
+ FT_ATOMIC_STORE_SSIZE_RELAXED (_PyUnicode_HASH (self ), x );
11397
11400
return x ;
11398
11401
}
11399
11402
0 commit comments