fix: ensure the GIL is held when copying a function. (#2545)

Co-authored-by: Hyrum Wright <hwright@google.com>
This commit is contained in:
Hyrum Wright 2020-10-02 17:00:45 -04:00 committed by GitHub
parent 1bcd5f0a19
commit 961b2e6205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,7 +58,10 @@ public:
struct func_handle {
function f;
func_handle(function&& f_) : f(std::move(f_)) {}
func_handle(const func_handle&) = default;
func_handle(const func_handle& f_) {
gil_scoped_acquire acq;
f = f_.f;
}
~func_handle() {
gil_scoped_acquire acq;
function kill_f(std::move(f));