]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-127065: Make methodcaller thread-safe and re-entrant (GH-127746)
authorPieter Eendebak <pieter.eendebak@gmail.com>
Wed, 11 Dec 2024 15:06:07 +0000 (16:06 +0100)
committerGitHub <noreply@github.com>
Wed, 11 Dec 2024 15:06:07 +0000 (10:06 -0500)
commitb0f278ff0551b06191cec01445c577e3b25570da
tree4a9117ecb9fbb404229a30536a3ae87ac68f4b2f
parent5a23994a3dbee43a0b08f5920032f60f38b63071
gh-127065: Make methodcaller thread-safe and re-entrant (GH-127746)

The function `operator.methodcaller` was not thread-safe since the additional
of the vectorcall method in gh-89013. In the free threading build the issue
is easy to trigger, for the normal build harder.

This makes the `methodcaller` safe by:

* Replacing the lazy initialization with initialization in the constructor.
* Using a stack allocated space for the vectorcall arguments and falling back
  to `tp_call` for calls with more than 8 arguments.
Lib/test/test_free_threading/test_methodcaller.py [new file with mode: 0644]
Lib/test/test_operator.py
Misc/NEWS.d/next/Library/2024-12-01-22-28-41.gh-issue-127065.tFpRer.rst [new file with mode: 0644]
Modules/_operator.c