From 9f204a18573d8a194549ad0fd51afdd3db5596e5 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Tue, 3 Aug 2021 13:15:48 -0400 Subject: [PATCH] fix: func_handle for rule of two (#3169) * Fix func_handle for rule of two * Apply reviewer suggestion --- include/pybind11/functional.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/pybind11/functional.h b/include/pybind11/functional.h index b9bf3891..bc8a8af8 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;