Avoids potential deadlocks with C++ static local initialization in
extensions that call PyUnicode_InternFromString during one-time
initialization.
(cherry picked from commit
f62050d65743f0c895f7e6d665936c4e86aa39d5)
Co-authored-by: Sam Gross <colesbury@gmail.com>
--- /dev/null
+Fix a potential deadlock in :c:func:`PyUnicode_InternFromString` and other
+interning functions in the :term:`free-threaded build` when called from C++
+static local initializers.
}
#endif
- FT_MUTEX_LOCK(INTERN_MUTEX);
+ FT_MUTEX_LOCK_FLAGS(INTERN_MUTEX, _Py_LOCK_DONT_DETACH);
PyObject *t;
{
int res = PyDict_SetDefaultRef(interned, s, s, &t);