@@ -206,20 +206,16 @@ static int
206206intern_constants (PyObject * tuple , int * modified )
207207{
208208 PyInterpreterState * interp = _PyInterpreterState_GET ();
209- PyObject * interned_dict = _Py_INTERP_CACHED_OBJECT (interp , interned_strings );
210209 // copypaste from unicodeobject.c
211- #ifdef Py_GIL_DISABLED
212- # define INTERN_MUTEX &_Py_INTERP_CACHED_OBJECT(interp, interned_mutex)
213- #endif
214- FT_MUTEX_LOCK (INTERN_MUTEX );
210+ PyObject * interned_dict = _Py_INTERP_CACHED_OBJECT (interp , interned_strings );
211+ Py_BEGIN_CRITICAL_SECTION (interned_dict );
215212 Py_INCREF (interned_dict );
216213 for (Py_ssize_t i = PyTuple_GET_SIZE (tuple ); -- i >= 0 ; ) {
217214 PyObject * v = PyTuple_GET_ITEM (tuple , i );
218215 if (PyUnicode_CheckExact (v ) && PyUnicode_GET_LENGTH (v ) > 1 ) {
219216 if (PyUnicode_CHECK_INTERNED (v ) != 0 ) {
220217 continue ;
221218 }
222- //
223219 PyObject * interned = PyDict_GetItemWithError (interned_dict , v );
224220 if (interned == NULL && PyErr_Occurred ()) {
225221 goto error ;
@@ -331,12 +327,12 @@ intern_constants(PyObject *tuple, int *modified)
331327 }
332328#endif
333329 }
334- FT_MUTEX_UNLOCK ( INTERN_MUTEX );
330+ Py_END_CRITICAL_SECTION ( );
335331 Py_DECREF (interned_dict );
336332 return 0 ;
337333
338334error :
339- FT_MUTEX_UNLOCK ( INTERN_MUTEX );
335+ Py_END_CRITICAL_SECTION ( );
340336 Py_DECREF (interned_dict );
341337 return -1 ;
342338}
0 commit comments