mirror of
https://github.com/RYDE-WORK/pybind11.git
synced 2026-02-04 06:23:30 +08:00
fix: ensure the GIL is held when copying a function. (#2545)
Co-authored-by: Hyrum Wright <hwright@google.com>
This commit is contained in:
parent
1bcd5f0a19
commit
961b2e6205
@ -58,7 +58,10 @@ public:
|
|||||||
struct func_handle {
|
struct func_handle {
|
||||||
function f;
|
function f;
|
||||||
func_handle(function&& f_) : f(std::move(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() {
|
~func_handle() {
|
||||||
gil_scoped_acquire acq;
|
gil_scoped_acquire acq;
|
||||||
function kill_f(std::move(f));
|
function kill_f(std::move(f));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user