diff --git a/include/pybind11/functional.h b/include/pybind11/functional.h index b9bf38919..bc8a8af82 100644 --- a/include/pybind11/functional.h +++ b/include/pybind11/functional.h @@ -70,9 +70,11 @@ public: struct func_handle { function f; func_handle(function &&f_) noexcept : f(std::move(f_)) {} - func_handle(const func_handle& f_) { + func_handle(const func_handle &f_) { operator=(f_); } + func_handle &operator=(const func_handle &f_) { gil_scoped_acquire acq; f = f_.f; + return *this; } ~func_handle() { gil_scoped_acquire acq;