]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-143880: Fix data race in `functools.partial` in free threading build (...
authorSam Gross <colesbury@gmail.com>
Fri, 16 Jan 2026 16:55:40 +0000 (11:55 -0500)
committerGitHub <noreply@github.com>
Fri, 16 Jan 2026 16:55:40 +0000 (22:25 +0530)
gh-143880: Fix data race in `functools.partial` in free threading build

The assignment to `pto->vectorcall` isn't thread-safe in the free
threading build. Note that this is already fixed in the main branch.

Misc/NEWS.d/next/Library/2026-01-15-13-03-22.gh-issue-143880.sWoLsf.rst [new file with mode: 0644]
Modules/_functoolsmodule.c

diff --git a/Misc/NEWS.d/next/Library/2026-01-15-13-03-22.gh-issue-143880.sWoLsf.rst b/Misc/NEWS.d/next/Library/2026-01-15-13-03-22.gh-issue-143880.sWoLsf.rst
new file mode 100644 (file)
index 0000000..b77f86e
--- /dev/null
@@ -0,0 +1 @@
+Fix data race in :func:`functools.partial` in the :term:`free threading` build.
index 3420e7d8c37b745b7cd97e74384467631df278a8..490c6b83d217b7f791e42756080e086023a23f22 100644 (file)
@@ -375,7 +375,9 @@ partial_vectorcall_fallback(PyThreadState *tstate, partialobject *pto,
                             PyObject *const *args, size_t nargsf,
                             PyObject *kwnames)
 {
+#ifndef Py_GIL_DISABLED
     pto->vectorcall = NULL;
+#endif
     Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
     return _PyObject_MakeTpCall(tstate, (PyObject *)pto, args, nargs, kwnames);
 }