https://github.com/python/cpython/commit/5125584767c48e32aef07c4d8f9a29a85e1a03b3 commit: 5125584767c48e32aef07c4d8f9a29a85e1a03b3 branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: kumaraditya303 <[email protected]> date: 2026-07-15T10:42:48Z summary:
[3.15] gh-150858: fix data race while changing `__qualname__` of a type object(GH-150859) (#153747) gh-150858: fix data race while changing `__qualname__` of a type object(GH-150859) (cherry picked from commit 1ec6596828b0db4317d85afa85e1f68a3551a07e) Co-authored-by: Thomas Kowalski <[email protected]> files: A Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-16-27-00.gh-issue-150858.j2dSkD.rst M Objects/typeobject.c diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-16-27-00.gh-issue-150858.j2dSkD.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-16-27-00.gh-issue-150858.j2dSkD.rst new file mode 100644 index 00000000000000..dcb932bf320629 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-03-16-27-00.gh-issue-150858.j2dSkD.rst @@ -0,0 +1 @@ +Fix a data race while changing ``__qualname__`` of a type concurrently on free-threaded builds. diff --git a/Objects/typeobject.c b/Objects/typeobject.c index f763f9f5eba58f..8108e8e92731da 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1594,7 +1594,12 @@ type_set_qualname(PyObject *tp, PyObject *value, void *context) } et = (PyHeapTypeObject*)type; - Py_SETREF(et->ht_qualname, Py_NewRef(value)); + PyInterpreterState *interp = _PyInterpreterState_GET(); + _PyEval_StopTheWorld(interp); + PyObject *old_qualname = et->ht_qualname; + et->ht_qualname = Py_NewRef(value); + _PyEval_StartTheWorld(interp); + Py_DECREF(old_qualname); return 0; } _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
