Skip to content

Commit 0042384

Browse files
authored
[3.14] gh-143880: Fix data race in functools.partial in free threading build (#143882)
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.
1 parent 8c250cf commit 0042384

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix data race in :func:`functools.partial` in the :term:`free threading` build.

Modules/_functoolsmodule.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,9 @@ partial_vectorcall_fallback(PyThreadState *tstate, partialobject *pto,
375375
PyObject *const *args, size_t nargsf,
376376
PyObject *kwnames)
377377
{
378+
#ifndef Py_GIL_DISABLED
378379
pto->vectorcall = NULL;
380+
#endif
379381
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
380382
return _PyObject_MakeTpCall(tstate, (PyObject *)pto, args, nargs, kwnames);
381383
}

0 commit comments

Comments
 (0)