◐ Shell
clean mode source ↗

gh-149816: Fix a race condition in `_PyBytes_FromList` with free-threading by sobolevn · Pull Request #149909 · python/cpython

_PyBytes_FromList is called from PyBytes_FromObject which does not own the passed object, so it is a borrowed reference.

Using _PyList_GetItemRef seems like the correct solution here.
However, I was not successful in actually triggering the failure without C-API direct usage.