Skip to content

Commit 724f3fa

Browse files
committed
Fix segfault due to list.pop by falling back to a generic method call
1 parent 0c1f104 commit 724f3fa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mypyc/lib-rt/list_ops.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,16 @@ void CPyList_SetItemUnsafe(PyObject *list, Py_ssize_t index, PyObject *value) {
237237

238238
PyObject *CPyList_PopLast(PyObject *obj)
239239
{
240+
#ifdef Py_GIL_DISABLED
241+
// The optimized version causes segfaults on a free-threaded Python 3.14b4 build,
242+
// at least on macOS, so fall back to a generic implementation.
243+
return PyObject_CallMethod(obj, "pop", NULL);
244+
#else
240245
// I tried a specalized version of pop_impl for just removing the
241246
// last element and it wasn't any faster in microbenchmarks than
242247
// the generic one so I ditched it.
243248
return list_pop_impl((PyListObject *)obj, -1);
249+
#endif
244250
}
245251

246252
PyObject *CPyList_Pop(PyObject *obj, CPyTagged index)

0 commit comments

Comments
 (0)